|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQ 6.0.2.7 JCA 1.5 and OC4J. Problems and Solutions |
« View previous topic :: View next topic » |
Author |
Message
|
GrolfCry |
Posted: Fri Jul 31, 2009 3:53 am Post subject: MQ 6.0.2.7 JCA 1.5 and OC4J. Problems and Solutions |
|
|
Newbie
Joined: 31 Jul 2009 Posts: 3
|
I want to share experiences on the use of JCA on OC4J 10.1.3.3.
1. Use JNDI problems.
If you use Queue definitions in JNDI - JСA dont work.
DestinationBuilder cannot resolve Queue instance type and throw ClassCastException in createDestination method.
See next posts... |
|
Back to top |
|
 |
GrolfCry |
Posted: Fri Jul 31, 2009 5:21 am Post subject: |
|
|
Newbie
Joined: 31 Jul 2009 Posts: 3
|
1. Use JNDI problems.
If you use Queue definitions in JNDI - JСA dont work.
DestinationBuilder cannot resolve Queue instance type and throw ClassCastException in createDestination method.
Solution:
Patch1. com.ibm.mq.connector.DestinationBuilder class:
Code: |
public static Destination createDestination(ActivationSpecImpl activationspecimpl)
throws ResourceException
{
JCATraceAdapter.traceEntry("DestinationBuilder.createDestination()");
...
if(ctx == null)
{
ctx = new InitialContext();
JCATraceAdapter.traceInfo("instantiated context: " + ctx);
}
JCATraceAdapter.traceInfo("looking up: " + activationspecimpl.getDestination());
obj1 = (Destination)ctx.lookup(activationspecimpl.getDestination());
JCATraceAdapter.traceInfo("found: " + obj1);
/* patch begin*/
if (obj1 instanceof MQQueueProxy){
obj1=(Destination)((MQQueueProxy)obj1).getQDestination();
JCATraceAdapter.traceInfo("get real dest: " + obj1);
}
/* patch end */
...
|
Patch2 Add Method to com.ibm.mq.connector.outbound.MQQueueProxy:
Code: |
public Destination getQDestination(){
return getMQDestination();
}
|
2. Backout message on processing error in OC4j. Message don't backout because JCA don't run afterDelivery if oc4j throw exception.
Solution:
Path1. com.ibm.mq.connector.inbound.WorkImpl class. Method run
Code: |
public void run()
{
if(JCATraceAdapter.isOn)
JCATraceAdapter.traceEntry("WorkImpl.run()");
...
try{ // patched, add try finally for theSession.run(); and run
//messageendpoint.afterDelivery(); on finally block
theSession.run();
}finally{ // patched line
if(JCATraceAdapter.isOn)
JCATraceAdapter.traceInfo("calling afterDelivery()");
messageendpoint.afterDelivery();
if(JCATraceAdapter.isOn)
JCATraceAdapter.traceInfo("message delivery completed");
} // patched line
}
catch(Throwable throwable)
{
JCAMessageBuilder.buildWarning("MQJCA4004", throwable);
}
...
|
3. Extend JСA. Cannot set up Listener Port in JNDI. Listener Port or equals 1414 or setup in MDB.
Solution - add port parameter to JCA.
patch1. RA.xml add lines:
Code: |
<!-- Administered objects -->
<adminobject>
<adminobject-interface>javax.jms.Queue</adminobject-interface>
<adminobject-class>
com.ibm.mq.connector.outbound.MQQueueProxy
</adminobject-class>
...
<!-- path begin-->
<config-property>
<config-property-name>port</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>1414</config-property-value>
</config-property>
<!-- path end-->
...
|
Patch2. Add port variables to MQQueueProxy:
Code: |
public String getPort()
{
JCATraceAdapter.traceEntry("MQQueueProxy.getPort()");
JCATraceAdapter.traceExit("MQQueueProxy.getPort()");
return port;
}
public void setPort(String _port)
{
JCATraceAdapter.traceEntry("MQQueueProxy.setPort()");
port =_port;
JCATraceAdapter.traceExit("MQQueueProxy.setPort()");
}
private String port="";
|
Patch3. ResourceAdapterImpl , add jndi initialization in method endpointActivation:
Code: |
public void endpointActivation(MessageEndpointFactory messageendpointfactory, ActivationSpec activationspec)
throws ResourceException
{
JCATraceAdapter.traceEntry("ResourceAdapterImpl.endpointActivation(...)");
try
{
if(inboundDisabled)
throw (ResourceException)JCAExceptionBuilder.buildException(0, "MQJCA1001");
if(activationspec instanceof ActivationSpecImpl)
{
boolean flag = messageendpointfactory.isDeliveryTransacted(onMessageMethod);
if(flag && "CLIENT".equalsIgnoreCase(((ActivationSpecImpl)activationspec).getTransportType()) && clientXaDisabled)
throw (ResourceException)JCAExceptionBuilder.buildException(0, "MQJCA1004");
JCATraceAdapter.traceInfo("endpoint transacted: " + flag);
JCATraceAdapter.traceInfo("activating " + activationspec);
activationspec.setResourceAdapter(this);
/* patch begin*/
ActivationSpecImpl activationspecimpl=(ActivationSpecImpl)activationspec;
if(activationspecimpl.getUseJNDI())
{
try{
if(ctx == null)
{
ctx = new InitialContext();
JCATraceAdapter.traceInfo("instantiated context: " + ctx);
}
JCATraceAdapter.traceInfo("looking up: " + activationspecimpl.getDestination());
Object obj1 = (Destination)ctx.lookup(activationspecimpl.getDestination());
JCATraceAdapter.traceInfo("found: " + obj1);
if (obj1 instanceof MQQueueProxy){
String port = ((MQQueueProxy)obj1).getPort();
if (port!=null && port!=""){
JCATraceAdapter.traceInfo("setting ActivationSpecImpl.Port: " + port);
activationspecimpl.setPort(port);
}
}
} catch(NamingException namingexception)
{
throw (ResourceException)JCAExceptionBuilder.buildException(0, "MQJCA0003", namingexception);
}
}
/* patch end */
javax.jms.Connection connection = theConnectionPool.allocateConnection((ActivationSpecImpl)activationspec, flag);
|
3. Sample Activation config in MDB:
Code: |
@MessageDriven
(name = "TestMQBean",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "WMQ/MQTest"),
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true")
})
@MessageDrivenDeployment(resourceAdapter = "WMQ")
public class TestMQBean implements MessageListener{
...
|
4. Sample oc4j-connectors.xml:
Code: |
<connector name="WMQ" path="WMQ.rar">
<security-permission enabled="false">
<description>Security Permissions for the JMS client</description>
<security-permission-spec>grant {
permission java.security.AllPermission;
};</security-permission-spec>
</security-permission>
<config-property name="connectionConcurrency" value="10"/>
<config-property name="maxConnections" value="30"/>
<config-property name="logWriterEnabled" value="true"/>
<config-property name="reconnectionRetryCount" value="5"/>
<config-property name="reconnectionRetryInterval" value="300000"/>
<config-property name="timestampsEnabled" value="true"/>
<config-property name="traceDestination" value="wmq_jms.log"/>
<config-property name="traceEnabled" value="true"/>
<config-property name="traceLevel" value="10"/>
<adminobject-config location="WMQ/MQTest">
<adminobject-class>com.ibm.mq.connector.outbound.MQQueueProxy</adminobject-class>
<config-property name="encoding" value="NATIVE"/>
<config-property name="expiry" value="UNLIMITED"/>
<config-property name="baseQueueName" value="TESTQ"/>
<config-property name="failIfQuiesce" value="true"/>
<config-property name="targetClient" value="MQ"/>
<config-property name="baseQueueManagerName" value="TESTQMGR"/>
<config-property name="CCSID" value="1208"/>
<config-property name="priority" value="QDEF"/>
<config-property name="persistence" value="PERS"/>
<config-property name="port" value="1415"/>
</adminobject-config>
...
|
5. oc4j-ra.xml
Code: |
<oc4j-connector-factories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/oc4j-connector-factories-10_0.xsd"
schema-major-version="10"
schema-minor-version="0">
<connector-factory location="WMQ/QueueConnectionFactory" connector-name="WMQ">
<config-property name="CCSID" value="1208"/>
<config-property name="channel" value="SRV.CONN"/>
<config-property name="failIfQuiesce" value="true"/>
<config-property name="hostName" value="127.0.0.1"/>
<config-property name="port" value="1414"/>
<config-property name="queueManager" value="TESTQMGR"/>
<config-property name="transportType" value="BINDINGS"/>
<config-property name="sslResetCount" value="1"/>
<connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
</connector-factory>
<connector-factory location="WMQ/XAQueueConnectionFactory" connector-name="WMQ">
<config-property name="CCSID" value="1208"/>
<config-property name="channel" value="SRV.CONN"/>
<config-property name="failIfQuiesce" value="true"/>
<config-property name="hostName" value="127.0.0.1"/>
<config-property name="port" value="1414"/>
<config-property name="queueManager" value="TESTQMGR"/>
<config-property name="transportType" value="BINDINGS"/>
<config-property name="sslResetCount" value="1"/>
<connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
</connector-factory>
</oc4j-connector-factories>
|
Thanks. It is works, but patch JCA is illegal.
Original info: http://smoggit.blogspot.com/2009/08/oracle-oc4j-10133-ibm-websphere-mq-6.html
Last edited by GrolfCry on Tue Aug 04, 2009 10:53 am; edited 1 time in total |
|
Back to top |
|
 |
GrolfCry |
Posted: Fri Jul 31, 2009 5:22 am Post subject: |
|
|
Newbie
Joined: 31 Jul 2009 Posts: 3
|
who knows how to ask IBM to change the JCA? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 31, 2009 6:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
GrolfCry wrote: |
who knows how to ask IBM to change the JCA? |
You should open a PMR. That is how you ask IBM to change the JCA. |
|
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
|
|
|
|