Service integration Bus was introduced in WAS 6, in simple terms it is a pure java based MQ Engine, it runs embedded within the server process, this is similar to Apache derby database used by WCS.
It is quite common in WCS implementation to post Messages through MQ layer to external systems, developing this in developer toolkit could be challenging as it requires Queue setup/external MQ etc...
In this blog I explore the possibility of making use of WAS SIB in WCS developer toolkit, this will help you to develop and validate your code for external MQ integration without a need to connect to your enterprise MQ Infrastructure.
I have taken a simple example of a Hello World XML which will be posted to a external Queue.
Let us start with setting up the necessary configuration for SIB.
1. Launch WAS Admin Console
https://localhost:9043/ibm/console/
2. Create a sample BUS with name "WCSBus", you can then add "server1" as the BUS member
3. Enable SIB Service as follows.
4. Now you need to create the standard WCS JMS Connection Factories.
5. Now you need to create WCS Queue definitions as follows.
Next we need to create a sample command which would post Message using WCS Message Mapper configuration.
1. Make Necessary DB entries for new Message Type
insert into msgtypes (MSGTYPE_ID,MSGTDIR,NAME,VIEWNAME,DESCRIPTION)
values ((SELECT MAX(MSGTYPE_ID)+1 FROM msgtypes),1,'HelloWorld','','Hello World MQ Message');
update keys
set counter= (SELECT MAX(MSGTYPE_ID)+1 FROM msgtypes)
where TABLENAME = 'msgtypes'
and COLUMNNAME = 'msgtype_id';
2. Create Message mapping from WCS Admin Console.
3. In My sample command I used following block of code to post the Message to MQ using the message mapper created in previous step.
SendMsgCmd SIBMsg = (SendMsgCmd) CommandFactory.createCommand("com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());
SIBMsg.setMsgType("HelloWorld");
SIBMsg.setStoreID(getStoreId());
String HelloMsg = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><message>Hello World</message>");
SIBMsg.setContent(null, "-1" , HelloMsg.getBytes());
SIBMsg.sendTransacted();
SIBMsg.setCommandContext(getCommandContext());
SIBMsg.execute();
4. Now hit the command from browser and you should notice an entry create in msgstore table and in few minutes you should be able to see the sample XML in the Queue destination as shown below.
Common Errors Encountered
=========================
When I was trying this out my WAS level was 7.0.0.7, You might see following error with this WCS WAS
The issue is with the JNDI name of WCS resource adaptors, this should be eis/JCAJMS, upgrade WAS to 7.0.0.11
this is the recommended versoin for WAS 7 FEP1, FEP2, once you upgrade, don't forget to publish WC project again
and this should remove the errors related to JNDI names.
if it did not fix the issue, completely remove the WC EAR from WAS and ADD again
[1/29/11 8:45:53:187 CST] 00000050 CommerceSrvr E JMSMessageBean sendImmediate CMN0422E: The following naming exception has occurred during processing: "lookup(eis/JCAJMS)javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: eis/JCAJMS: First component in name JCAJMS not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]".
[1/29/11 8:45:53:218 CST] 00000050 CommerceSrvr E com.ibm.commerce.messaging.outboundservice.SendTransactedMsgCmdImpl assembleMsg() CMN8216E: An error com.ibm.commerce.exception.ECSystemException: The following naming exception has occurred during processing: "lookup(eis/JCAJMS)javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: eis/JCAJMS: First component in name JCAJMS not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]". occurred while sending the message.
Rerence Links
- Very Good link on SIB
https://www.ibm.com/developerworks/mydeveloperworks/blogs/woolf/entry/service_integration_bus?lang=en
It is quite common in WCS implementation to post Messages through MQ layer to external systems, developing this in developer toolkit could be challenging as it requires Queue setup/external MQ etc...
In this blog I explore the possibility of making use of WAS SIB in WCS developer toolkit, this will help you to develop and validate your code for external MQ integration without a need to connect to your enterprise MQ Infrastructure.
I have taken a simple example of a Hello World XML which will be posted to a external Queue.
Let us start with setting up the necessary configuration for SIB.
1. Launch WAS Admin Console
https://localhost:9043/ibm/console/
2. Create a sample BUS with name "WCSBus", you can then add "server1" as the BUS member
3. Enable SIB Service as follows.
4. Now you need to create the standard WCS JMS Connection Factories.
5. Now you need to create WCS Queue definitions as follows.
Next we need to create a sample command which would post Message using WCS Message Mapper configuration.
1. Make Necessary DB entries for new Message Type
insert into msgtypes (MSGTYPE_ID,MSGTDIR,NAME,VIEWNAME,DESCRIPTION)
values ((SELECT MAX(MSGTYPE_ID)+1 FROM msgtypes),1,'HelloWorld','','Hello World MQ Message');
update keys
set counter= (SELECT MAX(MSGTYPE_ID)+1 FROM msgtypes)
where TABLENAME = 'msgtypes'
and COLUMNNAME = 'msgtype_id';
2. Create Message mapping from WCS Admin Console.
3. In My sample command I used following block of code to post the Message to MQ using the message mapper created in previous step.
SendMsgCmd SIBMsg = (SendMsgCmd) CommandFactory.createCommand("com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());
SIBMsg.setMsgType("HelloWorld");
SIBMsg.setStoreID(getStoreId());
String HelloMsg = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><message>Hello World</message>");
SIBMsg.setContent(null, "-1" , HelloMsg.getBytes());
SIBMsg.sendTransacted();
SIBMsg.setCommandContext(getCommandContext());
SIBMsg.execute();
4. Now hit the command from browser and you should notice an entry create in msgstore table and in few minutes you should be able to see the sample XML in the Queue destination as shown below.
Common Errors Encountered
=========================
When I was trying this out my WAS level was 7.0.0.7, You might see following error with this WCS WAS
The issue is with the JNDI name of WCS resource adaptors, this should be eis/JCAJMS, upgrade WAS to 7.0.0.11
this is the recommended versoin for WAS 7 FEP1, FEP2, once you upgrade, don't forget to publish WC project again
and this should remove the errors related to JNDI names.
if it did not fix the issue, completely remove the WC EAR from WAS and ADD again
[1/29/11 8:45:53:187 CST] 00000050 CommerceSrvr E JMSMessageBean sendImmediate CMN0422E: The following naming exception has occurred during processing: "lookup(eis/JCAJMS)javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: eis/JCAJMS: First component in name JCAJMS not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]".
[1/29/11 8:45:53:218 CST] 00000050 CommerceSrvr E com.ibm.commerce.messaging.outboundservice.SendTransactedMsgCmdImpl assembleMsg() CMN8216E: An error com.ibm.commerce.exception.ECSystemException: The following naming exception has occurred during processing: "lookup(eis/JCAJMS)javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: eis/JCAJMS: First component in name JCAJMS not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]". occurred while sending the message.
Rerence Links
- Very Good link on SIB
https://www.ibm.com/developerworks/mydeveloperworks/blogs/woolf/entry/service_integration_bus?lang=en