I was written a simple MessageListener(MDB) it is working fine.How to handle runtime exceptions in this.
[Ex: if was try to deploy this listener with a wrong queue name like "XXXX" instead of right one that time it is showing Exceptions and moreover deployment failure also coming.]
So how to avoid this type of Exceptions is there any Annotations are available.
And I tried to handle inside the below Class(ORANGE_QUEUE_MDB). But the control is not coming to inside .
Please help me how to solve this type of Errors.
#MessageDriven(name="WEBSPHERE_MDB",
activationConfig = {
#ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener"),
#ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "ORANGE.QUEUE"),
#ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
#ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.CONN"),
#ActivationConfigProperty(propertyName = "hostName", propertyValue = "192.168.22.29"),
#ActivationConfigProperty(propertyName = "queueManager", propertyValue = "manager"),
#ActivationConfigProperty(propertyName = "port", propertyValue = "1414"),
#ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),
#ActivationConfigProperty(propertyName = "username", propertyValue = "mqm"),
#ActivationConfigProperty(propertyName = "password", propertyValue = "password")
},
mappedName = "ORANGE.QUEUE",
messageListenerInterface = MessageListener.class)
#ResourceAdapter(value = "wmq.jmsra.rar")
#TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
#ApplicationException(rollback = true)
public class ORANGE_QUEUE_MDB extends RuntimeException implements MessageListener
{
public void onMessage(Message message) {
try{
TextMessage textMessage=(TextMessage) message;
}
catch(Exception e)
{
e.printStackTrace();
}
When I deploy above listener(with wrong queue name) in Jboss it is showing below exception
The Exception is like below :
11:17:14,630 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START:
org.jboss.msc.service.StartException in service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
Caused by: java.lang.RuntimeException: com.ibm.mq.connector.DetailedResourceException: MQJCA0001: An exception occurred in the JMS layer.
See the linked exception for details., error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown.
See the linked exception for details of the failure.
at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:171)
at org.jboss.as.ee.component.ComponentStartService.start(ComponentStartService.java:44)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
**Caused by: com.ibm.mq.connector.DetailedResourceException:** MQJCA0001: An exception occurred in the JMS layer. See the linked exception for details.,
error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown. See the linked exception for details of the failure.
at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:124)
at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:100)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:351)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.<init>(MessageEndpointDeployment.java:301)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:463)
at org.jboss.jca.core.rar.EndpointImpl.activate(EndpointImpl.java:164)
at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:169)
... 6 more
**Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'OORANGE.QUEUE'.**
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error. Use the linked exception to determine the cause of this error.
Check that the specified queue and queue manager are defined correctly.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:520)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:236)
at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:128)
at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.initialize(WMQConsumerShadow.java:856)
at com.ibm.msg.client.wmq.internal.WMQAsyncConsumerShadow.initialize(WMQAsyncConsumerShadow.java:724)
at com.ibm.msg.client.wmq.internal.WMQConnectionBrowser.<init>(WMQConnectionBrowser.java:1230)
at com.ibm.msg.client.wmq.internal.WMQConnection.createConnectionBrowser(WMQConnection.java:872)
at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionBrowser(JmsConnectionImpl.java:922)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.createConnectionBrowser(JmsConnectionConsumerImpl.java:238)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:166)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:116)
at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionConsumer(JmsConnectionImpl.java:415)
at com.ibm.mq.jms.MQConnection.createConnectionConsumer(MQConnection.java:215)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.createConnectionConsumer(MessageEndpointDeployment.java:486)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:331)
... 10 more
**Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2085' ('MQRC_UNKNOWN_OBJECT_NAME').**
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223)
... 23 more
How to handle these exceptions and replace with Userdefind custom error message. Like (Queue Configuration error please check) etc.
Related
I am trying to use the [JCA resoruce-adapters][1] to use an MDB to connect to kafka.
Following are the entries in the standalone-full.xml to configure the kafka resoruce adapter and the related ejb-mdb definition :
Note that the i have deploying the mdb as part of an ejbModule which is embeded in an ear
While deploying the application i get the below error
22:43:53,073 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.subunit."kafkatemplatereceiver.ear"."kafkatemplatereceiverEJB.jar".component.KafkaMDB.CREATE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."kafkatemplatereceiver.ear"."kafkatemplatereceiverEJB.jar".component.KafkaMDB.CREATE: Failed to start service
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type fish.payara.cloud.connectors.kafka.api.KafkaListener found in resource adapter kafka
at org.jboss.as.ejb3#21.0.2.Final//org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentCreateService.createActivationSpecs(MessageDrivenComponentCreateService.java:142)
at org.jboss.as.ejb3#21.0.2.Final//org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentCreateService.createComponent(MessageDrivenComponentCreateService.java:105)
at org.jboss.as.ee#21.0.2.Final//org.jboss.as.ee.component.BasicComponentCreateService.start(BasicComponentCreateService.java:86)
at org.jboss.as.ejb3#21.0.2.Final//org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentCreateService.start(MessageDrivenComponentCreateService.java:93)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc#1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
22:43:53,076 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "kafkatemplatereceiver.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"kafkatemplatereceiver.ear\".\"kafkatemplatereceiverEJB.jar\".component.KafkaMDB.CREATE" => "Failed to start service
Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type fish.payara.cloud.connectors.kafka.api.KafkaListener found in resource adapter kafka"}}
22:43:53,077 ERROR [org.jboss.as.server] (External Management Request Threads -- 1) WFLYSRV0021: Deploy of deployment "kafkatemplatereceiver.ear" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"kafkatemplatereceiver.ear\".\"kafkatemplatereceiverEJB.jar\".component.KafkaMDB.CREATE" => "Failed to start service
Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type fish.payara.cloud.connectors.kafka.api.KafkaListener found in resource adapter kafka"}}
**standalone-full.xml**
<subsystem xmlns="urn:jboss:domain:ejb3:8.0">
<session-bean>
<stateless>
<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
</stateless>
<stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
<singleton default-access-timeout="5000"/>
</session-bean>
<mdb>
<!--<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:kafka-rar-0.6.0.rar}"/>-->
<resource-adapter-ref resource-adapter-name="kafka"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb> ...
standalone-full.xml resource adapter configuration
<subsystem xmlns="urn:jboss:domain:resource-adapters:6.0">
<resource-adapters>
<resource-adapter id="kafka">
<archive>
kafka-rar-0.6.0.rar
</archive>
<transaction-support>XATransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="fish.payara.cloud.connectors.kafka.outbound.KafkaManagedConnectionFactory" jndi-name="java:/KafkaConnectionFactory" enabled="true" pool-name="ConnectionFactory">
<xa-pool>
<min-pool-size>1</min-pool-size>
<initial-pool-size>1</initial-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>false</prefill>
<is-same-rm-override>false</is-same-rm-override>
</xa-pool>
</connection-definition>
</connection-definitions>
</resource-adapter>
</resource-adapters>
</subsystem>
MDB Class:
package com.zhun.euon.service;
import java.util.Date;
import javax.ejb.MessageDriven;
import javax.ejb.ActivationConfigProperty;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.jboss.ejb3.annotation.ResourceAdapter;
//import com.zhun.euon.service.serializer.Stringo;
import fish.payara.cloud.connectors.kafka.api.KafkaListener;
import fish.payara.cloud.connectors.kafka.api.OnRecord;
#MessageDriven(activationConfig = {
#ActivationConfigProperty(propertyName = "clientId", propertyValue = "testClient"),
#ActivationConfigProperty(propertyName = "groupIdConfig", propertyValue = "test-consumer-group"),
#ActivationConfigProperty(propertyName = "topics", propertyValue = "zhun_core_data_service_topic"),
#ActivationConfigProperty(propertyName = "bootstrapServersConfig", propertyValue = "192.168.0.105:9092"),
#ActivationConfigProperty(propertyName = "autoCommitInterval", propertyValue = "100"),
#ActivationConfigProperty(propertyName = "retryBackoff", propertyValue = "1000"),
#ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "1000") ,
// #ActivationConfigProperty(propertyName="resourceAdapterName",propertyValue="kafka-rar-0.6.0.rar"),
// #ActivationConfigProperty(propertyName="resourceAdapterMid",propertyValue="kafka-rar-0.6.0.rar"),
#ActivationConfigProperty(propertyName = "keyDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"),
#ActivationConfigProperty(propertyName = "valueDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"),
})
#ResourceAdapter(value="kafka")
public class KafkaMDB implements KafkaListener {
#OnRecord( topics={"zhun_core_data_service_topic"})
public void getMessageTest(ConsumerRecord<String,String> record) {
System.out.println("Got record on topic testing " + record + "at time"+ new Date());
}
}
I am not sure if I am missing something, however i am unable to figure out why the server will look for the Listener's Interface implementation in the rar file itself and not in my EJB- Jar which is withing rth
[1]: https://github.com/payara/Cloud-Connectors/tree/master/Kafka/KafkaRAR
I was facing a similar issue. What ended up fixing this problem was by adding a jboss-deployment-structure.xml file under webapp/WEB-INF/. This pointed to the Kafka RAR that had been deployed with the JBoss Server:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.kafka-rar-0.6.1-SNAPSHOT.rar" export="TRUE"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
This was the tutorial I was following -> http://www.mastertheboss.com/other/jboss-stuff/apache-kafka/getting-started-with-apache-kafka-and-wildfly
I'm trying to configure WildFly 10.1.0 to use MDB's with context of the remote ActiveMQ server. Problem occures when trying to use injected remote JMSContext - naming exception(looking for transaction). Steps I did:
WildFly standalone-full.xml configuration: (only added entries are listed)
Output Socket Binding
<socket-binding-group>
...
<outbound-socket-binding name="remote-artemis">
<remote-destination host="192.168.56.10" port="61616"/>
</outbound-socket-binding>
</socket-binding-group>
Messaging configuration
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-artemis" user="foo" password="bar"/>
</server>
Naming Configuration - where external context is configured
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:/remote/artemis/" module="org.wildfly.extension.messaging-activemq" class="javax.naming.InitialContext" cache="true">
<environment>
<property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
<property name="java.naming.provider.url" value="tcp://192.168.56.10:61616"/>
</environment>
</external-context>
</bindings>
<remote-naming/>
</subsystem>
Standalone Artemis ActiveMQ configuration (server is running on linux as a service)
added foo=bar user, with admin rights
JAAS Security is used
added queue name="example.queue" to tms broker
Usage
Sample Consumer
#MessageDriven(name = "MessageConsiumer", activationConfig = {
#ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:/jms/remoteCF"),
#ActivationConfigProperty(propertyName="user", propertyValue="foo"),
#ActivationConfigProperty(propertyName="password", propertyValue="bar"),
#ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/remote/artemis/dynamicQueues/example.queue"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class MessageConsiumer implements MessageListener {
#Override
public void onMessage(Message message) {
try {
TextMessage msg = (TextMessage) message;
System.out.println(msg.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Sample Producer
public class MessageProducer {
#Inject
#JMSConnectionFactory("java:/jms/remoteCF")
#JMSPasswordCredential(userName = "foo", password = "bar")
private JMSContext context;
#Resource(lookup = "java:/remote/artemis/dynamicQueues/example.queue")
private Queue queue;
#PostConstruct
public void send(){
TextMessage msg = context.createTextMessage();
msg.setText("Sample text");
context.createProducer().send(queue, msg);
}
Result
It seems that JMSContext and destination Queue is injected properly(debugged). Error occures at runtime, on first JMSContext usage i.e.:
TextMessage msg = context.createTextMessage();
Naming exception is popping out, looking for comp/TransactionSynchronizationRegistry.
Is that up to standalone activeMQ transaction configuration? Or maybe is that wildfly's side? Any ideas what might that be?
Stacktrace
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: comp/TransactionSynchronizationRegistry -- service jboss.naming.context.java.comp.TransactionSynchronizationRegistry
at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:134)
at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getTransactionSynchronizationRegistry(InjectedJMSContext.java:109)
at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.isInTransaction(InjectedJMSContext.java:98)
at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getDelegate(InjectedJMSContext.java:87)
at org.wildfly.extension.messaging.activemq.deployment.injection.JMSContextWrapper.createProducer(JMSContextWrapper.java:66)
at testr.messaging.MessageProductioner.sendThat(MessageProductioner.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:57)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:95)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:57)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.tx.EjbBMTInterceptor.handleInvocation(EjbBMTInterceptor.java:103)
... 49 more
Caused by: javax.naming.NameNotFoundException: comp/TransactionSynchronizationRegistry -- service jboss.naming.context.java.comp.TransactionSynchronizationRegistry
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:223)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:132)
... 74 more
I have been playing with a lot of Jboss parameters but I have been unsuccessful in getting my MDB to process more than 10 concurrent messages at a time. This is not adequate for my needs - I need a lot more concurrent message processing. I've completely run out of ideas. Does anyone have any suggestions?
My MDB (Had everything defined as a aspect domain but moved it):
#MessageDriven(name = "Incoming Task MDB", activationConfig = {
#ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "TaskQueue"),
#ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false") })
#TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
#TransactionManagement(value = TransactionManagementType.BEAN)
// #AspectDomain("Task Queue MDB") JBOSS Specific annotation to inject the MQ server session at runtime
#ResourceAdapter("wmq.jmsra.rar")
#org.jboss.ejb3.annotation.DefaultActivationSpecs ({
#javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "..."),
#javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "..."),
#javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "..."),
#javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1414"),
#javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),
#javax.ejb.ActivationConfigProperty(propertyName = "pollingInterval", propertyValue = "250"),
#javax.ejb.ActivationConfigProperty(propertyName = "rescanInterval", propertyValue = "250"),
#ActivationConfigProperty(propertyName="minSession",propertyValue="100"),
#ActivationConfigProperty(propertyName="maxSession",propertyValue="100") })
#org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=100, timeout=10000)
public final class IncomingTaskMDB extends TaskCompletionReportable implements MessageListener {
The wmq.jmsra.rar version:
Specification-Title: J2EE Connector Architecture
Specification-Version: 1.5
Implementation-Title: WebSphere MQ Resource Adapter
Implementation-Version: 7.0.1.3-k701-103-100812
Implementation-Vendor: IBM Corporation
In my wmq.jmsra.rar - I modified the ra.xml:
<resourceadapter>
<resourceadapter-class>
com.ibm.mq.connector.ResourceAdapterImpl
</resourceadapter-class>
<config-property>
<config-property-name>connectionConcurrency</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>100</config-property-value>
</config-property>
<config-property>
<config-property-name>maxConnections</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>100</config-property-value>
</config-property>
In my ejb3-interceptors-aop.xml:
<domain name="Message Driven Bean" extends="Intercepted Bean" inheritBindings="true">
<bind pointcut="execution(public * *->*(..))">
<interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
</bind>
<!-- TODO: Authorization? -->
<bind pointcut="execution(public * *->*(..))">
<interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
<!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
<stack-ref name="EJBInterceptors"/>
</bind>
<annotation expr="class(*) AND !class(#org.jboss.ejb3.annotation.Pool)">
#org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=100, timeout=10000)
</annotation>
In standardjboss.xml:
<invoker-proxy-binding>
<name>message-driven-bean</name>
<invoker-mbean>default</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
<proxy-factory-config>
<JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
<ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
<CreateJBossMQDestination>false</CreateJBossMQDestination>
<!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
<MinimumSize>1</MinimumSize>
<MaximumSize>100</MaximumSize>
<KeepAliveMillis>30000</KeepAliveMillis>
<MaxMessages>1</MaxMessages>
<MDBConfig>
<ReconnectIntervalSec>10</ReconnectIntervalSec>
<DLQConfig>
<DestinationQueue>queue/DLQ</DestinationQueue>
<MaxTimesRedelivered>10</MaxTimesRedelivered>
<TimeToLive>0</TimeToLive>
</DLQConfig>
</MDBConfig>
</proxy-factory-config>
</invoker-proxy-binding>
Use the annotation to increase the sessions generated from wsmq libraries. Default is 10.
#ActivationConfigProperty(propertyName = "maxPoolDepth", propertyValue = "100"),
Tying to launch my .ear on a Local JBoss 6.1.0 Final with local ActiveMQ. As I'm starting the Jboss. I get:
09:56:52,300 INFO [org.jboss.ejb3.deployers.JBossASKernel] Created KernelDeployment for: message-service-ejb-1.0-SNAPSHOT.jar
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] installing bean: jboss.j2ee:ear=message-service-ear-1.0-SNAPSHOT,jar=message-service-ejb-1.0-SNAPSHOT.jar,name=MedhjalparService,service=EJB3
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] with dependencies:
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] and demands:
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] jboss.ejb:service=EJBTimerService; Required: Described
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] jboss-switchboard:appName=message-service-ear-1,module=message-service-ejb-1.0-SNAPSHOT,name=MedhjalparService; Required: Create
09:56:52,304 INFO [org.jboss.ejb3.deployers.JBossASKernel] and supplies:
09:56:52,305 INFO [org.jboss.ejb3.deployers.JBossASKernel] jndi:null
09:56:52,305 INFO [org.jboss.ejb3.deployers.JBossASKernel] Class:javax.jms.MessageListener
09:56:52,307 INFO [org.jboss.ejb3.deployers.JBossASKernel] Added bean(jboss.j2ee:ear=message-service-ear-1.0-SNAPSHOT,jar=message-service-ejb-1.0-SNAPSHOT.jar,name=MedhjalparService,service=EJB3) to KernelDeployment of: message-service-ejb-1.0-SNAPSHOT.jar
09:56:52,347 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=jboss.j2ee:ear=message-service-ear-1.0-SNAPSHOT,jar=message-service-ejb-1.0-SNAPSHOT.jar,name=MedhjalparService,service=EJB3 state=Create: java.lang.IllegalStateException: No pool annotation
at org.jboss.ejb3.EJBContainer.initializePool(EJBContainer.java:1325) [:1.7.21]
at org.jboss.ejb3.mdb.MessagingContainer.initializePool(MessagingContainer.java:357) [:1.7.21]
And heres the code:
#MessageDriven(name = "MessageMDBSample", activationConfig = {
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/MyQueue"),
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}
public class ExampleMDBean implements MessageListener{
private static final long serialVersionUID = 1L;
public void onMessage
I was using the wrong activeMQ-rar.rar. the one int deployment had a versionnumber in the filename and the configuration I was using did not..
I am trying to understand some EJB 3 code running in JBoss 4.3.
We've got an ejb3-interceptors-aop.xml file configured in JBoss with some MDB configuration and then we've got the MDB Java class.
What I'd like to understand is when and how does the MDB get "bound" to the MQ? That is, when/how does the MDB start listening to the MQ queue?
Does JBoss at startup read the ejb3-interceptors-aop.xml file and then find the class with the AspectDomain annotation equal to "GatewayMDB" and "bind" to the MQ queue at startup?
XML in ejb3-interceptors-aop.xml:
<domain name="GatewayMDB">
<bind pointcut="execution(public * #javax.annotation.security.RunAs->*(..))">
<interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
</bind>
<bind pointcut="execution(public * *->*(..))">
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
</bind>
<annotation expr="!class(#org.jboss.annotation.ejb.PoolClass)">
#org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(#org.jboss.annotation.ejb.DefaultActivationSpecs)">
#org.jboss.annotation.ejb.DefaultActivationSpecs ({#javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.SVRCONN"), #javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "10.10.10.10"), #javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM"), #javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1419"),#javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")})
</annotation>
</domain>
MDB class:
#MessageDriven(name = "BridgeMDB", activationConfig = {
#ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "TO.WLS.LQUEUE.BG"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "maxPoolDepth", propertyValue = "1") })
#ResourceAdapter("wmq.jmsra.rar")
#AspectDomain("GatewayMDB")
#Interceptors(SpringBeanAutowiringInterceptor.class)
#TransactionManagement(TransactionManagementType.CONTAINER)
public class BridgeMDB implements MessageListener {
private static Logger logger = Logger.getLogger(BridgeMDB.class);
#Autowired
private MessageProcessor messageProcessor;
#Autowired
private MessageTranslator messageTranslator;
#TransactionAttribute(TransactionAttributeType.REQUIRED)
public void onMessage(Message message) {
...
}
}
Disclaimer: this is a supposition, since I don't know the jboss code.
The common way of processing class files in java is to read them through the class path (in this case it would be at load-time) and construct some sort of metadata for each class.
Then, when the application bootstraps the container will read the class's metadatada to wire/inject/configure the appropriate attributes that were defined within the class.
As for the xml, most of the jboss configuration is static AFAIK, ie, you have to restart the app server in order for changes to take effect.
So all in all, I would say that your observation is correct.
For a clear understanding of this process, your best bet would be to read the JCA specification. It is a clearly and easily understandable spec.
IBM provides their JCA adapter which is deployed to JBoss. When JBoss deploys your MDB, an "activation specification" is passed to the IBM JCA. The IBM JCA then creates a managed connection factory for the MDB instances. Note that this is separate and distinct from any connection factories as configured in the JBoss server configuration.
Part of the activation spec is the number of JMS sessions. The IBM JCA creates and manages these sessions. The IBM JCA also create JMS message listeners on these sessions.
When a message is received, the IBM JCA creates a message driven context, requests an MDB instance from the JBoss managed instance pool, provides the message driven context to the MDB instance and calls the MDB onMessage() method.