Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Overview of the ServiceMix 2.x JMS Binding Example

This document The following procedure describes how to run the JMS Binding example and provides details about regarding what it does. For information on the business use case, please refer to: Use Case for JMS Binding.

The JMS Binding example illustrates the following:

  • use of declarative programming
  • how to perform JMS integration in ServiceMix
  • how to use an ActiveMQ message broker
  • how to use the Jencks JCA container
  • how to use the Geronimo Transaction Manager via the Jencks factory bean

...

  1. From a command shell, go to the JMS Binding example directory:
    Code Block
    cd [servicemix_install_dir]\src\release\examples\jms-binding
    
    where servicemix_install_dir is the directory in which ServiceMix was installed.
  2. Then type:
    Code Block
    [servicemix_install_dir]\src\release\bin\servicemix servicemix.xml
    
  3. To start the sending and receiving of message messages from the JMS topics, send it a JMS an initial message. To do this, compile and run a simple JMS client. The client is built and run from source code using Ant. Execute Ant from the JMS Binding directory: servicemix_install_dir\src\release\examples\jms-binding. To run the JMS client type:
    Code Block
    ant
    

    Ant will compile and run the simple JMS client, JMSClient, which performs a JMS based request-response into the ServiceMix container before returning the results to the console.

...

To terminate the JMS Binding example, type "CTRL-C" in the command shell in which it is running and answer "y" to the "Terminate batch job (y/n)?" question.

...

The diagram below illustrates the flow of messages through the JMS Binding components. :

Panel
borderColor#ccc
titleJMS Binding Example Message Flow Diagram
borderStylesolid

...

Code Block
  
Loading ServiceMix from file: C:\exist\servicemix\servicemix-12.0.1\examples\jms--binding\servicemix.xml
[INFO] XmlBeanDefinitionReaderXBeanXmlBeanDefinitionReader - -Loading XML bean definitions from file [C:\exist\servicemix\servicemix-12.0.1\examples\jms-binding\servicemix.xml]
[INFO] FileSystemXmlApplicationContext - -Bean factory for application context 
[org.xbean.springframeworkspring.context.support.FileSystemXmlApplicationContext;hashCode=110292022540508]: 
 org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans 
[jbi,jencks,broker,
transactionContextManager,transactionManager,jmsFactory,jbi]; root of BeanFactory hierarchy
[INFO] FileSystemXmlApplicationContext - -56 beans defined in application context [org.springframeworkxbean.spring.context.support. FileSystemXmlApplicationContext;hashCode=110292022540508]
[INFO] CollectionFactory - -JDK 1.4+ collections available
[INFO] CollectionFactory - -Commons Collections 3.x available
[INFO] FileSystemXmlApplicationContext - -Unable to locate MessageSource with name 'messageSource': using default 
[org.springframework.context.support.DelegatingMessageSource@1971afcDelegating
MessageSource@a8c488]
[INFO] FileSystemXmlApplicationContext - -Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': 
 using default [org.springframework.context.event.SimpleApplicationEventMulticaster@cdedfdSimpleApplicationEventMulticaster@76cbf7]
[INFO] DefaultListableBeanFactory - -Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory 
defining beans
 [jbi,jencks,broker,transactionContextManager,transactionManager,jmsFactory,jbi]; root of BeanFactory hierarchy]
[INFO] DefaultListableBeanFactorySpringBrokerContainerFactory - Loading -CreatingActiveMQ sharedbroker instancefrom ofconfiguration: singleton bean'jencks'
[INFO] DefaultListableBeanFactory - -Creating shared instance of singleton bean'broker'
[INFO] SpringBrokerContainerFactory - -Loading ActiveMQ broker from configuration: class class path resource [activemq.xml]
[INFO] ActiveMQBeanDefinitionReader - -Loading XML bean definitions from class path resource [activemq.xml]
[INFO] ActiveMQBeanFactoryBrokerContainerImpl - -Creating shared instance of singleton bean 'broker'ActiveMQ 3.2 JMS Message Broker (ID:el2tong-1857-1132035585799-1:0) is starting
[INFO] ActiveMQBeanFactoryBrokerContainerImpl - -CreatingFor sharedhelp instanceor ofmore singletoninformation bean 'memoryManager'
[INFO] ActiveMQBeanFactory - -Creating shared instance of singleton bean 'derby-ds'please see: http://www.logicblaze.com
[INFO] JDBCPersistenceAdapter - Database driver recognized: [apache_derby_embedded_jdbc_driver]
[INFO] ActiveMQBeanFactoryDefaultJDBCAdapter - -CreatingCould sharednot instancecreate ofJDBC singletontables; bean 'mysql-ds'
[INFO] BrokerContainerImpl - -ActiveMQ 3.1-M6 JMS Message Broker (ID:el2tong-3108-1131439169538-0:0) is starting
[INFO] BrokerContainerImpl - -For help or more information please see: http://www.logicblaze.com
[INFO] JDBCPersistenceAdapter - -Database driver recognized: [apache_derby_embedded_jdbc_driver]they could already exist. Failure was: 
CREATE TABLE ACTIVEMQ_MSGS(ID INTEGER NOT NULL, CONTAINER VARCHAR(250), MSGID VARCHAR(250), MSG BLOB, PRIMARY KEY ( ID ) ) Message: Table/View
'ACTIVEMQ_MSGS' already exists in Schema 'APP'. SQLState: X0Y32 Vendor code: 20000
[INFO] DefaultJDBCAdapter - -Could not create JDBC tables; they could already exist. Failure was:
 CREATE TABLE ACTIVEMQ_MSGSTXS(ID INTEGERXID VARCHAR(250) NOT NULL, CONTAINERPRIMARY VARCKE
HARY (250), MSGIDXID VARCHAR(250), MSG BLOB, PRIMARY KEY ( ID ) ) Message: Table/View 'ACTIVEMQ_MSGSTXS' already exists in Schema 'APP'. SQLState: X0Y32 Vendor code: 20000
[INFO] DefaultJDBCAdapter - -Could not create JDBC tables; they could already exist. 
Failure was: CREATE TABLE ACTIVEMQ_TXSACKS(XIDSUB VARCHAR(250) NOT NULL, PRIMARYCONTAINER
 KEY ( XID )) Message: Table/View 'ACTIVEMQ_TXS' already exists in Schema 'APP'. S
QLState: X0Y32 Vendor code: 20000
VARCHAR(250) NOT NULL, LAST_ACKED_ID INTEGER, SE_ID INTEGER, SE_CLIENT_ID VARCHAR(250), SE_CONSUMER_NAME VARCHAR(250), SE_SELECTOR VARCHAR(250), PRIMARY KEY (
SUB, CONTAINER )) Message: Table/View 'ACTIVEMQ_ACKS' already exists in Schema 'APP'. SQLState: X0Y32 Vendor code: 20000
[INFO] DefaultJDBCAdapter - -Could not create JDBC tables; they could already exist. Failure was: CREATEALTER TABLE ACTIVEMQ_ACKS(SUB VARCHAR(250) NOT NULL, CONTAINER 
VARCHAR(250) NOT NULL, LAST_ACKED_ID INTEGER, SE_ID INTEGER, SE_CLIENT_ID VARCHAR(250), SE_CONSUMER_NAME VARCHAR(250), SE_SELECTOR VARCHAR(250), PRIMARY KEY (
 SUB, CONTAINER )) Message: Table/View 'ACTIVEMQ_ACKSMSGS ADD EXPIRATION BIGINT Message: Column
 'EXPIRATION' already exists in Table/View 'APP.ACTIVEMQ_MSGS'. SQLState: X0Y32 Vendor code: 20000
[INFO] DefaultJDBCAdapter - Could not create JDBC tables; they could already exist. Failure was: ALTER TABLE ACTIVEMQ_MSGS ADD SENT_TO_DEADLETTER CHAR(1) 
Message: Column 'SENT_TO_DEADLETTER' already exists in SchemaTable/View 'APP.ACTIVEMQ_MSGS'. SQLState: X0Y32 Vendor code: 20000
[INFO] DefaultJDBCAdapterJournalPersistenceAdapter - -Could not create JDBC tables; they could already exist. Failure was: ALTER TABLE ACTIVEMQ_MSGS ADD EXPIRATION BIGINT Message: 
Column 'EXPIRATION' already exists in Table/View 'APP.ACTIVEMQ_MSGS'. SQLState: X0Y32 Vendor code: 20000
[INFO] JournalPersistenceAdapter - -Opening journalOpening journal.
[INFO] JournalPersistenceAdapter - Opened journal: Active Journal: using 2 x 20.0 Megs at: ..\var\journal
[INFO] JournalPersistenceAdapter - Journal Recovery Started.
[INFO] JournalPersistenceAdapter - Journal Recovered: 0 message(s) in transactions recovered.
[INFO] JournalPersistenceAdapterTcpTransportServerChannel - -OpenedListening journal:for Activeconnections Journal: using 2 x 20.0 Megs at: ..\var\journalat: tcp://el2tong:61616
[INFO] JournalPersistenceAdapterBrokerConnectorImpl - -Journal Recovery Started.ActiveMQ connector started: TcpTransportServerChannel@tcp://el2tong:61616
[INFO] JournalPersistenceAdapterBrokerContainerImpl - -JournalActiveMQ Recovered:JMS 1Message message(s) in transactions recovered.Broker (ID:el2tong-1857-1132035585799-1:0) has started
[INFO] TcpTransportServerChannelJCAContainer - -ListeningJencks forJCA connectionsContainer at: tcp://el2tong:61616(http://jencks.org/) has started running version: 1.1
[INFO] BrokerConnectorImplSpringInitialContextFactory - -ActiveMQ connector started: TcpTransportServerChannel@tcp://el2tong:61616Loading JNDI context from: class path resource [jndi.xml]
[INFO] BrokerContainerImplXBeanXmlBeanDefinitionReader - -ActiveMQ JMS Message Broker (ID:el2tong-3108-1131439169538-0:0) has startedLoading XML bean definitions from class path resource [jndi.xml]
[INFO] DefaultListableBeanFactoryJBIContainer - -Creating shared instance of singleton bean 'transactionManager' Activating component for: [container=defaultJBI,name=#SubscriptionManager#,id=#SubscriptionManager#]
 with service: null component: org.servicemix.jbi.nmr.SubscriptionManager@1315415
[INFO] DefaultListableBeanFactoryJBIContainer - -Creating shared instance of singleton bean 'jmsFactory'ServiceMix JBI Container (http://servicemix.org/) name: defaultJBI running version: 2.0.1
[INFO] DefaultListableBeanFactoryJBIContainer - -CreatingActivating shared instance of singleton bean 'jbi'
[INFO] component for: [container=defaultJBI,name=inputReceiver,id=inputReceiver]
 with service: {http://servicemix.org/demo/}inputReceiver component: org.servicemix.components.jms.JmsInUsingJCABinding@1786a3c
[INFO] JCAConnector - -Activating endpoint for activationSpec: ActiveMQActivationSpec{acknowledgeMode='Auto-acknowledge', destinationType='javax.jms.Topic', mesmess
sageSelectorageSelector='null', destination='demo.org.servicemix.source', clientId='null',
 subscriptionName='null', subscriptionDurability='NonDurable'} using endpointFactendpointFacto
oryry: org.jencks.SingletonEndpointFactory@2803d5SingletonEndpointFactory@d0d12e[transactionManager=null]
[INFO] ActiveMQConnection - -channel status changed: Channel: TcpTransportChannel: Socket[addr=localhost/127.0.0.1,port=61616,localport=3109] has connected
[INFO] BrokerContainerImpl - -Adding new client: ID:el2tong-3108-1131439169538-6:0 
on transport: TcpTransportChannel: Socket[addr=/127.0.0.1,port=3109,localport=61616]
[INFO] SpringInitialContextFactory - -Loading JNDI context from: class path resource [jndi.xml]
[INFO] XmlBeanDefinitionReader - -Loading XML bean definitions from class path resource [jndi.xml]
[INFO] XmlBeanFactory - -Creating shared instance of singleton bean 'jndi'
[INFO] JBIContainer - -ServiceMix JBI Container (http://servicemix.org/) name: defaultJBI running version: ServiceMix.
[INFO] JBIContainer - -Activating component for: [container=defaultJBI,name=inputReceiver,id=inputReceiver] with service: {http://servicemix.org/demo/}inputRece
iver component: org.servicemix.components.jms.JmsInUsingJCABinding@98f192
[INFO] ComponentContextImpl - -Component: inputReceiver activated endpoint: {http://servicemix.org/demo/}inputReceiver : inputReceiver
[INFO] JBIContainer - -Activating component for: [container=defaultJBI,name=outputSender,id=outputSender] with service: {http://servicemix.org/demo/}outputSende
r component: org.servicemix.components.jms.JmsSenderComponent@1d5b89c
[INFO] ComponentContextImpl - -Component: outputSender activated endpoint: {http://servicemix.org/demo/}outputSender : outputSender
[INFO] JCAContainer - -Jencks JCA Container (http://jencks.org/) has started running version: 1.0-M1
[INFO] BrokerContainerImpl - -Adding new client: ID:el2tong-3114-1131439189647-1:0 on transport: TcpTransportChannel: Socket[addr=/127.0.0.1,port=3115,localport=61616]
[INFO] DeliveryChannel - -default destination serviceName for inputReceiver =org.apache.geronimo.transaction.context.GeronimoTransactionManager@1554233]
[INFO] ComponentContextImpl - Component: inputReceiver activated endpoint: {http://servicemix.org/demo/}inputReceiver : inputReceiver
[INFO] JBIContainer - Activating component for: [container=defaultJBI,name=outputSender,id=outputSender] with service:
 {http://servicemix.org/demo/}outputSender component: org.servicemix.components.jms.JmsSenderComponent@1c6d11a
[INFO] ActiveMQConnectionComponentContextImpl - -channelComponent: statusoutputSender changed:activated Channelendpoint: TcpTransportChannel: Socket[addr=localhost/127.0.0.1,port=61616,localport=3116] has connected{http://servicemix.org/demo/}outputSender : outputSender
[INFO] BrokerContainerImplActiveMQConnection - -Addingchannel newstatus clientchanged: ID:el2tong-3108-1131439169538-17:0 on 
transport: Channel: TcpTransportChannel: Socket[addr=localhost/127.0.0.1,port=311661616,localport=616161863] has connected
[INFO] BrokerContainerImpl - -RemovingAdding new client: ID:el2tong-31141857-11314391896471132035585799-111:0 on transport: 
TcpTransportChannel:
 Socket[addr=/127.0.0.1,port=31151863,localport=61616]

Details

The following table provides more details about the function of each component and bean in the servicemix.xml file.

Component or Bean ID

Description

jbi

jbi is the "id" of the JBI container and provides the basic infrastructure services for the following components: inputReceiver and outputSender. During initialization, several singletons are instantiated: transactionManager, broker, jencks, jmsFactory, and jbi. After initialization, the components in the jbi container are activated.

inputReceiver

This component uses jencks , the JCA container, to listen on port 61616 for a JMS message on the topic called "demo.org.servicemix.source." inputReceiver subscribes to the demo.org.servicemix.source topic. It takes the message, normalizes it, and routes it to outputSender via the NMR. This component combined with outputSender and supporting beans creates a JMS bridge between two topics.

outputSender

This component receives a normalized message from the NMR, marshals it into a JMS message using jmsTemplate (1), then publishes it on the ActiveMQ (JMS) topic called "demo.org.servicemix.result."

jencks

The jencks bean defines a JCA container. The JCA container allows you to configure thread pool size, configure a transaction manager, and configure a resource adapter. In this example, the resource adapter is an ActiveMQ adapter, however, another any JMS listener could be configured instead. This adapter listens on port 61616 for JMS messages.

broker

The broker bean uses the activemq.xml file to configure the message broker, which handles the JMS messages for the components that require JMS messaging services.

transactionManager

This bean is configured to be the default transaction manager for the jbi container. jencks is configured to use the default transaction manager. This transaction manager provides transactional services between the resource adapter (in this case the ActiveMQ resource adapter provided by the jencks JCA container) and components the jbi container.

jmsFactory

This bean listens on port 61616 and provides a pooled ActiveMQ connection.

...