Author |
Message
|
anilit99 |
Posted: Mon Jun 29, 2009 2:57 am Post subject: How to set TARGCLIENT property ? |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
Hello there,
Can you please tell me how to set the TARGCLIENT property using JMS ?
This is my setup :
App Server: JBoss
Resource Adapter : wmq.jmsra.rar
1. I've binded the MQConnectionFactory visible in the global name space.
2. To post a message I just look up this connection factory and use JMS objects to post the message.
Can I set this field using JMS API or should I use the MQ API for java and remove the problem altogether ?
thanks
Anil. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 29, 2009 2:59 am Post subject: Re: How to set TARGCLIENT property ? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
anilit99 wrote: |
Can I set this field using JMS API or should I use the MQ API for java and remove the problem altogether ?
|
It's always best to use the JMS unless you have a seriously good reason not to. This doesn't seem all that good.
A quick search of the forum turned up a number of discussions that sounded useful in the setting of this value. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
anilit99 |
Posted: Mon Jun 29, 2009 4:32 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
Hi Vitor !
thanks a ton ! really a fast reply !
Forums like these really help guys like me to venture into any exciting technology without much fear !
thanks
Anil. |
|
Back to top |
|
 |
anilit99 |
Posted: Mon Jun 29, 2009 9:10 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
Fixed !
I am using JBoss and posting messages using MQ resource adapter.
If you are using a similar setup, the easiest way to set all the properties exposed on the MQ classes for JMS is setting them on the resource adapter. No explicit JMS administration.
Code: |
<mbean code="org.jboss.resource.deployment.AdminObject" name="jboss.jca:service=WASDestination,name=dev_request_queue">
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<attribute name="JNDIName">request_queue</attribute>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=test_QM
baseQueueName=dev_request_queue
targetClient=JMS
</attribute>
</mbean>
|
thanks Vitor !
cheers
Anil. |
|
Back to top |
|
 |
hsq125 |
Posted: Wed Aug 05, 2009 7:22 am Post subject: ClassCastException while retrieving QueueConnectionFactory |
|
|
Newbie
Joined: 05 Aug 2009 Posts: 2
|
Hi!!
I am also using JBoss (version 5) and posting messages using MQ resource adapter ( wmq.jmsra.rar, right ?) , which is configured with the following xml file copied into /usr/local/jboss/server/default/deploy
Code: |
<connection-factories>
<!-- JCA Connection factory definitions -->
<tx-connection-factory>
<jndi-name>MQCF</jndi-name>
<xa-transaction />
<rar-name>wmq.jmsra.rar</rar-name>
<connection-definition>javax.jms.ConnectionFactory</connection-definition>
<config-property name="channel" type="java.lang.String">SYSTEM.DEF.SVRCONN</config-property>
<config-property name="hostName" type="java.lang.String">sputnik</config-property>
<config-property name="port" type="java.lang.String">1414</config-property>
<config-property name="queueManager" type="java.lang.String">QM_MERCATOR.SPUTNIK.TEST</config-property>
<config-property name="transportType" type="java.lang.String">CLIENT</config-property>
</tx-connection-factory>
<!-- mbeans defining JCA administered objects -->
<mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=RequestQueue">
<attribute name="JNDIName">jca:/mq/jmsra/JCAAdminObject/RequestQueue</attribute>
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=QM_MERCATOR.SPUTNIK.TEST
baseQueueName=Q_APCA.INPUT
targetClient=JMS
</attribute>
</mbean>
</connection-factories>
|
I put message into the RequestQueue queue with the following java code
Code: |
@Stateless
@TransactionAttribute(javax.ejb.TransactionAttributeType.SUPPORTS)
@Local(IJMS.class)
public class JMS implements IJMS {
private final long timeout = 120000;
@Resource(name = "jms.broker")
private String connectionFactoryName="java:MQCF";
@Resource(name = "jms.queue.request")
private String requestQueueName="jca:/mq/jmsra/JCAAdminObject/RequestQueue";
@Resource(name = "jms.queue.reply")
private String replyQueueName="jca:/mq/jmsra/JCAAdminObject/ReplyQueue";
protected Logger log = Logger.getLogger(this.getClass());
@Override
@TransactionAttribute(javax.ejb.TransactionAttributeType.REQUIRES_NEW)
public String putMessage(String message) throws IJMSException {
if (log.isDebugEnabled()) {
log.debug("putMessage (" + message + ")");
}
if (message == null) {
ExceptionUtils.exception(new IJMSException(IJMSException.REQUEST_MESSAGE_CANNOT_BE_NULL), log);
}
String messageId = null;
QueueConnectionFactory connectionFactory = null;
QueueConnection connection = null;
QueueSession session = null;
try {
Context jndiContext = new InitialContext();
connectionFactory = (QueueConnectionFactory) jndiContext.lookup(connectionFactoryName);
Queue requestQueue = (Queue) jndiContext.lookup(requestQueueName);
connection = connectionFactory.createQueueConnection();
connection.start();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(requestQueue);
sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage textMessage = session.createTextMessage();
textMessage.setText(message);
sender.send(textMessage);
// Use our own correlation id instead of JMSCorrelationID
// messageId = textMessage.getJMSMessageID();
messageId = XMLRequestResponseHelper.getRequestIDFromXMLRequest(message);
sender.close();
session.close();
connection.close();
connection = null;
} catch (JMSException e) {
// Pass the exception back to the caller
ExceptionUtils.exception(new IJMSException(e), log);
} catch (NamingException e) {
// Pass the exception back to the caller
ExceptionUtils.exception(new IJMSException(e), log);
} finally {
// Ensure that the Connection always gets closed
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
ExceptionUtils.exception(new IJMSException(e), log);
}
}
}
if (log.isDebugEnabled()) {
log.debug("messageId=" + messageId);
}
return messageId;
}
|
When executing it, i get the following error in the jboss logs
Code: |
javax.ejb.EJBException: java.lang.ClassCastException: com.ibm.mq.connector.outbound.ConnectionFactoryImpl cannot be cast to javax.jms.QueueConnectionFactory org.eib.apca2.eai_interface.fpk.exception.EAIException: javax.ejb.EJBException: java.lang.ClassCastException: com.ibm.mq.connector.outbound.ConnectionFactoryImpl cannot be cast to javax.jms.QueueConnectionFactory
at org.eib.apca2.eai_interface.fpk.session_bean.AbstractEAI.request(AbstractEAI.java:62)
at org.eib.apca2.eai_interface.fpk.session_bean.CachingEAI.request(CachingEAI.java:97)
at org.eib.apca2.eai_interface.fpk.session_bean.AbstractEAI.request(AbstractEAI.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
|
... I understand the reason, but I don't know how to fix it. It's not clear for me where to make the difference between the JMS part and the MQ part.
Could some please help me ??
Thanks a lot !!!!!!!!!!!!
Octave  |
|
Back to top |
|
 |
anilit99 |
Posted: Wed Aug 05, 2009 7:33 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
Code: |
<mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=RequestQueue"> |
can you replace the above line with this :
Code: |
<mbean code="org.jboss.resource.deployment.AdminObject" name="jboss.jca:service=WASDestination, name= RequestQueue"> |
_________________ "I almost care !" |
|
Back to top |
|
 |
hsq125 |
Posted: Wed Aug 05, 2009 7:55 am Post subject: |
|
|
Newbie
Joined: 05 Aug 2009 Posts: 2
|
Thank you for your response ... mmmh I always get the same error.
Here is the logs that JBoss 5 generates when I deploy my MQ resource adapater, maybe it can help ...
Code: |
17:55:23,391 INFO [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=MQCF' from JNDI name 'java:MQCF'
17:55:23,413 INFO [AdminObject] Unbound admin object at 'jca:/mq/jmsra/JCAAdminObject/ReplyQueue'
17:55:23,419 INFO [AdminObject] Unbound admin object at 'jca:/mq/jmsra/JCAAdminObject/RequestQueue'
17:55:23,578 INFO [AdminObject] Bound admin object 'com.ibm.mq.connector.outbound.MQQueueProxy' at 'jca:/mq/jmsra/JCAAdminObject/RequestQueue'
17:55:23,611 INFO [AdminObject] Bound admin object 'com.ibm.mq.connector.outbound.MQQueueProxy' at 'jca:/mq/jmsra/JCAAdminObject/ReplyQueue'
17:55:23,653 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=MQCF' to JNDI name 'java:MQCF'
|
|
|
Back to top |
|
 |
anilit99 |
Posted: Wed Aug 05, 2009 8:04 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
I believe the code snippet has nothing to do with your error. I accidentally submitted the post, before I could say that it is the recommended way to define the admin object. _________________ "I almost care !" |
|
Back to top |
|
 |
|