|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Non server specific EAR files |
« View previous topic :: View next topic » |
Author |
Message
|
Juan Bustamante |
Posted: Tue Oct 09, 2007 11:03 am Post subject: Non server specific EAR files |
|
|
Newbie
Joined: 09 Oct 2007 Posts: 1
|
I am currently working on a project that uses an MDB to read messages off of an MQ queue, process them, and then write the response to another queue on the same queue manager.
The issue that we are having is that we have server specific data such as the hostname, queue name to drain from etc. within our ejb-jar.xml. This is a hastle for our build team because they require a new EAR file for each JBoss server they deploy the application on. My question is the following. Is there a way to separate the server specific data from the ejb-jar.xml?
The technologies that we use are IBM Websphere MQ Explorer with fixpack 6.0.2, JBoss AS 4.0.5.GA, java 1.5_011.
The following is a sample EJB definition from our ejb-jar.xml.
Code: |
<message-driven>
<ejb-name>Listener1</ejb-name>
<ejb-class>qualified class name</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>EJBName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Listener1</env-entry-value>
</env-entry>
<env-entry>
<!-- The JNDI name of the connection factory used -->
<!-- to send the response. -->
<env-entry-name>connectionFactory</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>java:ConnFactory</env-entry-value>
</env-entry>
<env-entry>
<!-- The JNDI location of the queue used -->
<!-- to send the response. -->
<env-entry-name>queueJndi</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>java:queue/</env-entry-value>
</env-entry>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>QUEUE.NAME</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useJNDI</activation-config-property-name>
<activation-config-property-value>false</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>myHost</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>queueManagerName</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>CLIENT</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>port</activation-config-property-name>
<activation-config-property-value>1414</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven> |
Thank you very much in advance,
Juan |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 09, 2007 11:13 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That's really a JBOSS question more than MQ question.
I suppose the admins could script something to update the XML file, too.
Does JBoss not provide JNDI? In a WAS environment, all that stuff would be JNDI name references rather than set values. Then the specific server or etc. would have a resolution of the JNDI name to the actual resource to use. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
dfranklin |
Posted: Wed Oct 17, 2007 6:35 pm Post subject: |
|
|
Newbie
Joined: 17 Oct 2007 Posts: 2
|
I have been trying to solve the same problem. I can get the wmq.jmsra.rar to work if I specify the MQ hostname in my ejb-jar.xml deployment descriptor, but I really want it to resolve to an existing Queue via local JNDI.
If the useJNDI parameter is set to true, it is supposed to resolve 'destination' as the JNDI name of an existing javax.jms.Queue object in the local JNDI namespace. That is according to the documentation here:
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40080_.htm
I cannot get that to work in JBoss. Here is how I tried to do it.
The AdminObject to bind the Queue to JNDI:
wmq-service.xml:
Code: |
<server>
<!--
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40120_.htm
-->
<mbean code="org.jboss.resource.deployment.AdminObject"
name="jboss.jca:service=WASDestination,name=ABCQueue">
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<attribute name="JNDIName">queue/abc</attribute>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=QM.ABC
baseQueueName=Q.ABC
</attribute>
</mbean>
</server> |
The ConnectionFactory:
wmq-ds.xml:
Code: |
<connection-factories>
<!--
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40080_.htm
-->
<tx-connection-factory>
<jndi-name>WMQConnectionFactory</jndi-name>
<xa-transaction/>
<rar-name>wmq.jmsra.rar</rar-name>
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
<config-property name="hostName" type="java.lang.String">mqhostname</config-property>
<config-property name="port" type="java.lang.String">1414</config-property>
<config-property name="queueManager" type="java.lang.String">QM.ABC</config-property>
<max-pool-size>20</max-pool-size>
</tx-connection-factory>
</connection-factories> |
The MDB:
In ejb-jar.xml:
Code: |
<message-driven>
<ejb-name>MyMDB</ejb-name>
<ejb-class>com.example.MyMDB</ejb-class>
<transaction-type>Bean</transaction-type>
<!--
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaw.doc/uj40080_.htm#uj40080___uj40080_2
-->
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>queue/abc</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useJNDI</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven> |
Since I have useJNDI set to true, I expect it to resolve "queue/abc" into the deployed javax.jms.Queue object. Instead, I get this error:
Code: |
javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:'
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:297)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:333)
at org.jboss.resource.deployment.RARDeployment.endpointActivation(RARDeployment.java:271)
at org.jboss.resource.deployment.RARDeployment.internalInvoke(RARDeployment.java:226)
at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:156)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.ejb.plugins.inflow.JBossMessageEndpointFactory.activate(JBossMessageEndpointFactory.java:484)
... 113 more
Caused by: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:614)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2480)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1830)
at com.ibm.mq.jms.MQConnection.<init>(MQConnection.java:811)
at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:4821)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.initializeJMSConnection(ResourceAdapterConnectionPool.java:445)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.createNewConnection(ResourceAdapterConnectionPool.java:359)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:284)
... 120 more |
I tried enabling trace logging in the MQ code by setting the following properties in properties-service.xml.
Code: |
<server>
<mbean code="org.jboss.varia.property.PropertyEditorManagerService"
name="jboss:type=Service,name=PropertyEditorManager">
</mbean>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
name="jboss:type=Service,name=SystemProperties">
<attribute name="Properties">
traceEnabled=true
traceDestination=/tmp/wmq.trace.log
traceLevel=10
logWriterEnabled=false
</attribute>
</mbean>
</server>
|
I think it is just trying to connect to localhost:1414. It doesn't appear to be using JNDI at all.
/tmp/wmq.trace.log:
Code: |
[17/10/07 18:38:12:110 PDT.4] ScannerThread QmgrName:
[17/10/07 18:38:12:110 PDT.5] ScannerThread Client Connection (CLIENT)
[17/10/07 18:38:12:110 PDT.6] ScannerThread Host : localhost
[17/10/07 18:38:12:110 PDT.7] ScannerThread Port : 1414
[17/10/07 18:38:12:110 PDT.8] ScannerThread Channel: SYSTEM.DEF.SVRCONN
....
[17/10/07 18:38:12:113 PDT.6] ScannerThread --->ResourceAdapterConnectionPool.createNewConnection(...)
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:614)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2480)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1830)
at com.ibm.mq.jms.MQConnection.<init>(MQConnection.java:811)
at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:4821)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.initializeJMSConnection(ResourceAdapterConnectionPool.java:445)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.createNewConnection(ResourceAdapterConnectionPool.java:359)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:284)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:333)
at org.jboss.resource.deployment.RARDeployment.endpointActivation(RARDeployment.java:271)
...
JMSException.getLinkedException():
com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:238)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:318)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:338)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:774)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:690)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:646)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:544)
at com.ibm.mq.MQSPIQueueManager.<init>(MQSPIQueueManager.java:69)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2401)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1830)
at com.ibm.mq.jms.MQConnection.<init>(MQConnection.java:811)
at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:4821)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.initializeJMSConnection(ResourceAdapterConnectionPool.java:445)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.createNewConnection(ResourceAdapterConnectionPool.java:359)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:284)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:333)
at org.jboss.resource.deployment.RARDeployment.endpointActivation(RARDeployment.java:271)
...
Caused by: com.ibm.mqservices.MQInternalException: MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
at com.ibm.mq.MQInternalCommunications.createSocketConnection(MQInternalCommunications.java:2366)
at com.ibm.mq.MQv6InternalCommunications$1.run(MQv6InternalCommunications.java:167)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.mq.MQv6InternalCommunications.initialize(MQv6InternalCommunications.java:164)
at com.ibm.mq.MQv6InternalCommunications.<init>(MQv6InternalCommunications.java:112)
at com.ibm.mq.MQSESSIONClient.MQCONNX(MQSESSIONClient.java:1348)
at com.ibm.mq.MQSESSIONClient.spiConnect(MQSESSIONClient.java:4550)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:205)
... 137 more
|
How can I deploy this in JBoss so that my MDB connects to the javax.jms.Queue without specifying the MQ host name in the ejb-jar.xml deployment descriptor? |
|
Back to top |
|
 |
dfranklin |
Posted: Thu Nov 01, 2007 3:22 pm Post subject: |
|
|
Newbie
Joined: 17 Oct 2007 Posts: 2
|
I found a very simple solution to this.
In jboss/.../deploy/properties-service.xml, add this:
Code: |
<attribute name="Properties">
wmq.hostName=mqhostname
wmq.port=1414
wmq.queueManager=QM.ABC
wmq.queueName=Q.ABC
</attribute> |
(You can also make it load the properties from a separate file.)
Now change the activation-config section in the deployment descriptor to use variables:
Code: |
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>${wmq.queueName}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useJNDI</activation-config-property-name>
<activation-config-property-value>false</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>${wmq.hostName}</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>${wmq.queueManager}</activation-config-property-value>
</activation-config-property>
</activation-config> |
You can do the same in wmq-ds.xml and wmq-service.xml, so all of your parameters are in one file.
wmq-ds.xml:
Code: |
<connection-factories>
<tx-connection-factory>
<jndi-name>WMQConnectionFactory</jndi-name>
<xa-transaction/>
<rar-name>wmq.jmsra.rar</rar-name>
<connection-definition>javax.jms.ConnectionFactory</connection-definition>
<config-property name="hostName" type="java.lang.String">${wmq.hostName}</config-property>
<config-property name="queueManager" type="java.lang.String">${wmq.queueManager}</config-property>
<max-pool-size>20</max-pool-size>
</tx-connection-factory>
</connection-factories> |
wmq-service.xml:
Code: |
<server>
<mbean code="org.jboss.resource.deployment.AdminObject"
name="jboss.jca:service=WSMQQueue,name=ABCMessageQueue">
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<attribute name="JNDIName">queue/abc</attribute>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=${wmq.queueManager}
baseQueueName=${wmq.queueName}
</attribute>
</mbean>
</server> |
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|