Using WAS Service integration Bus with WebSphere Commerce Developer

Posted by Unknown on
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

4 comments:

  1. Hi,Starting a website is not an easy task, so making a Web Design Cochin and development plan is the right decision. Good website planning is a first step in the website development process.Thanks............

    ReplyDelete
  2. Hari,
    What should be the implementation strategy to have an inbound message command to be store specific. ie, NewInboundMessageCmd should invoke CmdImpl1 for message related to store A and invoke CMdImpl2 for messge related to Store2.

    ReplyDelete
  3. Well explained. Got to learn new things from your Blog on Coded UI.Coded UI Training in Chennai

    ReplyDelete
  4. Some good points made here. I have a different take on a couple details but the overall message rings true. Well written piece that covered the main topics comprehensively. A few minor facts could be checked but the gist seems on point. tarpaulin

    ReplyDelete