Thursday 19 January 2012

Apache ActiveMQ with Webphere commerce

  • Download the latest release of Apache ActiveMQ from http://activemq.apache.org/download.html
  • The active-mq setup files are downloaded in zipped
  • Extract the contents of the folder of your choice. E.g. C:\Installs\Apache Software Foundation\apache-activemq-5.4.3\
  • The folder “\apache-activemq-5.4.3\bin” would be considered as the ACTIVEMQ_HOME
  • Navigate to C:\Installs\Apache Software Foundation\apache-activemq-5.4.3\bin in a command window and execute “activemq.bat”.
  • The Active MQ JMS server starts with following startup options
    • Requests are listened at port 61616 by default
      • tcp://127.0.0.1:61616
    • Admin console for administering and monitoring ActiveMQ
      • http://127.0.0.1:8161/admin
  • Hit http://127.0.0.1:8161/admin and you can create and administer the queues. (Not part of the purpose of this tutorial)
    • If you are behind the firewall of a corporate n/w and proxy settings are applied on your Internet connection, please ensure to exclude “localhost” & “127.0.0.1” in the “No proxy for” list in Internet connection settings.
    • Navigate to the admin console and select “Queue” to create the below queues
      • JMSSerialInboundQueue
      • JMSParallelInboundQueue
      • JMSErrorQueue
      • JMSOutboundQueue
  • Now, the JMS provider will be configured in the WAS admin console
    • Place the following jar files in WAS classpath

      C:\IBM\SDP\runtimes\base_v7\lib\ext. These jars will be available in the ACTIVEMQ installation_dir\lib folder
      • activeio-core-3.1.2
      • activemq-core-5.4.3
      • commons-logging-1.1
      • geronimo-j2ee-management_1.1_spec-1.0.1
      • geronimo-jms_1.1_spec-1.1.1
      • geronimo-jta_1.0.1B_spec-1.0.1
      • kahadb-5.4.3
    • Open WAS admin console, navigate to Resources -> JMS -> JMS provider
      • Select Scope --> Node=Localhost, Server=server1
      • Select New
      • Give a name of your choice --> e.g., ActiveMQJMSProvider
      • External initial context factory --> org.apache.activemq.jndi.ActiveMQInitialContextFactory
      • External provider URL --> tcp://127.0.0.1:61616
    • Custom properties required for binding the JNDI name defined in ActiveMQ with the JNDI name defined in WAS (WC-Server.xml)
      • Select “ActiveMQJMSProvider” from JMS Providers(or the one which you created in the previous step)
      • Under “Additional properties” select “Custom properties”
      • Click New and add the following four properties
        • Name – connectionFactoryNames, Value-queueConnectionFactory
        • Name-queue.JMSErrorQueue, Value-JMSErrorQueue
        • Name-queue.JMSOutboundQueue, value-JMSOutboundQueue
        • Name-queue.JMSParallelInboundQueue, value-JMSParallelInboundQueue
        • Name-queue.JMSSerialInboundQueue, value-JMSSerialInboundQueue
    • Configuring ‘Queues’ in WAS admin console – for the queues created in ActiveMQ admin console. (Please use JNDI names of your choice, for simplicity reasons, I’ve used the same JNDI names for defining the physical queues and WAS JNDI binding configuration)
      • JMSErrorQueue
        • Click New
        • Node --> Node=localhost,Server=server1
        • Provider --> ActiveMQJMSProvider
        • Name --> JMSErrorQueue
        • Type --> Queue
        • JNDI Name --> JMSErrorQueue
        • External JNDI Name --> JMSErrorQueue
        • Click Apply and save the configuration
      • JMSOutboundQueue
        • Click New
        • Node --> Node=localhost,Server=server1
        • Provider --> ActiveMQJMSProvider
        • Name --> JMSOutboundQueue
        • Type --> Queue
        • JNDI Name --> JMSOutboundQueue
        • External JNDI Name --> JMSOutboundQueue
        • Click Apply and save the configuration
      • JMSParallelInboundQueue
        • Click New
        • Node --> Node=localhost,Server=server1
        • Provider --> ActiveMQJMSProvider
        • Name --> JMSParallelInboundQueue
        • Type --> Queue
        • JNDI Name --> JMSParallelInboundQueue
        • External JNDI Name --> JMSParallelInboundQueue
        • Click Apply and save the configuration
      • JMSSerialInboundQueue
        • Click New
        • Node --> Node=localhost,Server=server1
        • Provider --> ActiveMQJMSProvider
        • Name --> JMSSerialInboundQueue
        • Type --> Queue
        • JNDI Name --> JMSSerialInboundQueue
        • External JNDI Name --> JMSSerialInboundQueue
        • Click Apply and save the configuration
    • Open WC-Server.xml, enable the MQ specific transport adapter.
      • Navigate to config-->Components-->component@compClassName=“com.ibm.commerce.messaging.listener.TransportAdapter”
      • If attribute enable=”false”, make it to enable=”true”
  • Restart the server, ensure that the ActiveMQ server is started while starting the WAS server.

Monday 8 August 2011

Websphere Commerce - Order Release flow

The following outlines about what should happen for an Order to get released for fulfillment. A schedular entry runs and invoks the following command for releasing Order for fulfillment.

ReleaseToFulfillmentCmd
This is used to release orders to a fulfillment center for a given store.
  • It identifies all the orders that needs to be released by executing Query.
  • For each order, 
    • if the current order is blocked, this order will not be further processed
    • Call ReleaseOrdersToFulfillmentCOCmd

ReleaseOrdersToFulfillmentCOCmd
Used for releasing an order for fulfillment.
  • The list of orders that are available for release are resolved by calling ResolveReleasesCmdImpl. This command updates ORDERREL table. This table holds the relationship between parent and child order. In an order, if an item is tied with "tieShip Code", this command will try to tie the item to 1. Future order or 2. Backorder or 3. Make the item available for release
  • For the list of orders ready for release, ReservePaymentCmd is called. Two things can happen,
    • If this command returns EDPResults.STATUS_SUCCESS_INT, and if all items are released for fulfillment, a storedProc is run to update the ORDER.STATUS to 'R'
    • For all other response from this command, items will not be released to fulfillment, they will be processed in the next scheduler job
    • Incase of an error in ReservePaymentCmd, a tickler is created withOrderConstants.TICKLER_FINANCIAL_TRANSACTION_ERROR

ReservePaymentCmd
This command is used to reserve payments in payment rules subcomponent and is associated with release to fulfillment.
The possible payment actions are: Approve, Deposit, ReverseApproval
E.g., A customer order is selected for fulfillment by the schedular. All the items are ready to be shipped, to the same location, thru same carrier at the same time. This command is called and
  • Payment rules are read
  • Payment actions are identified
  • Payment instructions are identified and are used in the order they are configured, based on the payment method configuration
Now, if the target state is approved, and was not previously approved, the payment will be approved now, else if it is already approved, re-approval will not happen, else if payment fails in the backend system, a tickler will be send to CSR.