Qpid client Apache Artemis 2.14.0 High availability not working - apache-camel

Connecting Apache Artemis broker using Qpid client for High Availablity.
The broker instance runs in two nodes and configuration listed with replication in broker.xml
Brokers instance started on node1 (master) and node2 (slave), and it was running without any issues.
The camel qpid jms client is configured with URL as failover:(amqp://localhost:5672,amqp://localhost:5673), on executing the camel client and the context started without any issue and also noticed the connection in Broker UI Console listed as AMQP protocol. [ configuration details provided below ]
With below configuration everything works fine.
To test High availablity, i stopped the broker instance on node1, and expected Qpid Camel client to automatically discover the node2 broker and process the message. But it didn't connect as expected.
But when i used aretmis-jms camel client with URL including tcp scheme connection, i was able to successfully validate the high availablity where when broker running in node1 is stopped for some reason client discovers broker on node2 automatically. Also when the node1 starts backup client automatically connects to node1.
The Qpid client is not able to discover the backup broker. Any issues in below configuration
master: For detail configuration refer link
<ha-policy>
<replication>
<master>
<check-for-live-server>true</check-for-live-server>
</master>
</replication>
</ha-policy>
slave:
<ha-policy>
<replication>
<slave>
<allow-failback>true</allow-failback>
</slave>
</replication>
</ha-policy>
Client uses camel
<bean id="jmsampqConnectionFactory" class="org.apache.qpid.jms.JmsConnectionFactory">
<property name="remoteURI" value="failover:(ampq://localhost:5672,ampq://localhost:5673)" />
<property name="username" value="user"/>
<property name="password" value="pass"/>
</bean>
<bean id="jmsPooledConnectionFactory" class="org.messaginghub.pooled.jms.JmsPoolConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="5" />
<property name="connectionFactory" ref="jmsamqpConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="jmsPooledConnectionFactory" />
<property name="concurrentConsumers" value="5" />
</bean>
<bean id="jms" class="org.apache.camel.component.amqp.AMQPComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
<bean id="CustomBean1" class="org.specific.process.class" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:queue:enterprise1.queue" />
<convertBodyTo type="java.lang.String" />
<bean ref="CustomBean1" method="processCamelExchangeData" />
</route>
</camelContext>
maven dependency
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-amqp-starter</artifactId>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.54.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-amqp</artifactId>
<version>2.23.0</version>
</dependency>
logs:
2020-09-17 20:15:18,684: main DEBUG (FailoverProvider.java:153) - Initiating initial connection attempt task
2020-09-17 20:15:18,690: main DEBUG (AbstractJmsListeningContainer.java:382) - Established shared JMS Connection
2020-09-17 20:15:18,692: main DEBUG (AbstractJmsListeningContainer.java:549) - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker#3962ec84
2020-09-17 20:15:18,692: main DEBUG (AbstractJmsListeningContainer.java:549) - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker#147e0734
2020-09-17 20:15:18,693: main DEBUG (AbstractJmsListeningContainer.java:549) - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker#2bdab835
2020-09-17 20:15:18,694: main DEBUG (AbstractJmsListeningContainer.java:549) - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker#7b8aebd0
2020-09-17 20:15:18,695: main DEBUG (AbstractJmsListeningContainer.java:549) - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker#55222ee9
2020-09-17 20:15:18,743: FailoverProvider: async work thread DEBUG (FailoverProvider.java:744) - Connection attempt:[1] to: amqp://localhost:5672 in-progress
2020-09-17 20:15:19,102: AmqpProvider :(1):[amqp://localhost:5672] DEBUG (SaslMechanismFinder.java:106) - Best match for SASL auth was: SASL-PLAIN
2020-09-17 20:15:19,119: FailoverProvider: async work thread DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsConnectionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1, configuredURI = failover:(amqp://localhost:5672,amqp://localhost:5673), connectedURI = null } (1)
2020-09-17 20:15:19,162: AmqpProvider :(1):[amqp://localhost:5672] DEBUG (AmqpConnectionBuilder.java:84) - AmqpConnection { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1 } is now open:
2020-09-17 20:15:19,164: AmqpProvider :(1):[amqp://localhost:5672] DEBUG (FailoverProvider.java:884) - Processing alternates uris:URI Pool { [amqp://localhost:5673, amqp://localhost:5672] } with new set: [amqp://localhost:61617?amqp.vhost=localhost]
2020-09-17 20:15:19,164: AmqpProvider :(1):[amqp://localhost:5672] DEBUG (FailoverProvider.java:899) - Replacing uris:URI Pool { [amqp://localhost:5673, amqp://localhost:5672] } with new set: [amqp://localhost:5672, amqp://localhost:61617?amqp.vhost=localhost]
2020-09-17 20:15:19,164: AmqpProvider :(1):[amqp://localhost:5672] DEBUG (FailoverProvider.java:913) - Processing alternates done new uris:URI Pool { [amqp://localhost:5672, amqp://localhost:61617?amqp.vhost=localhost] }
2020-09-17 20:15:19,165: AmqpProvider :(1):[amqp://localhost:5672] INFO (JmsConnection.java:1339) - Connection ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1 connected to server: amqp://localhost:5672
2020-09-17 20:15:19,168: main DEBUG (JmsConsumer.java:106) - Started listener container org.apache.camel.component.jms.DefaultJmsMessageListenerContainer#5e9bf744 on destination enterprise1.queue
2020-09-17 20:15:19,168: main INFO (DefaultCamelContext.java:4013) - Route: route1 started and consuming from: jms://queue:enterprise1.queue
2020-09-17 20:15:19,169: main DEBUG (DefaultCamelContext.java:3989) - Route: route2 >>> EventDrivenConsumerRoute[jmsTopic://topic:enterprise2.topic -> Pipeline[[Channel[convertBodyTo[java.lang.String]], Channel[org.apache.camel.component.bean.BeanProcessor#69d103f0]]]]
2020-09-17 20:15:19,169: main DEBUG (DefaultCamelContext.java:3993) - Starting consumer (order: 1001) on route: route2
2020-09-17 20:15:19,216: Camel (camel) thread #4 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsSessionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:1 } (2)
2020-09-17 20:15:19,216: Camel (camel) thread #5 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsSessionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:2 } (3)
2020-09-17 20:15:19,216: Camel (camel) thread #6 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsSessionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:3 } (4)
2020-09-17 20:15:19,217: Camel (camel) thread #7 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsSessionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:4 } (5)
2020-09-17 20:15:19,238: Camel (camel) thread #8 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsSessionInfo { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:5 } (6)
2020-09-17 20:15:19,361: Camel (camel) thread #4 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: create -> JmsConsumerInfo: { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:1:1, destination = enterprise1.queue } (7)
2020-09-17 20:15:19,362: main DEBUG (DefaultManagementAgent.java:470) - Registered MBean with ObjectName: org.apache.camel:context=camel,type=consumers,name=JmsConsumer(0x1132baa3)
2020-09-17 20:15:19,362: main DEBUG (DefaultConsumer.java:144) - Starting consumer: Consumer[jmsTopic://topic:enterprise2.topic]
2020-09-17 20:15:19,364: main DEBUG (FailoverProvider.java:153) - Initiating initial connection attempt task
2020-09-17 20:15:19,365: main DEBUG (AbstractJmsListeningContainer.java:382) - Established shared JMS Connection
...
2020-09-17 20:15:22,486: Camel (camel) thread #7 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: start -> JmsConsumerInfo: { ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:4:1, destination = enterprise1.queue } (40)
2020-09-17 20:15:22,490: Camel (camel) thread #5 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: message pull -> ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:2:1 (41)
2020-09-17 20:15:22,491: Camel (camel) thread #4 - JmsConsumer[enterprise1.queue] DEBUG (FailoverProvider.java:1159) - Executing Failover Task: message pull -> ID:0229e4fb-1885-4a10-8b55-04a7a0a450a5:1:1:1 (42)
...

The client is receiving an update of known broker URIs from the Artemis server it connects to which seems to only know about a server running with port 61617 advertised. This is resulting in the client replacing the URIs with the new set returned from the broker which is shown in the logs:
Replacing uris:URI Pool { [amqp://localhost:5673, amqp://localhost:5672] } with new set: [amqp://localhost:5672, amqp://localhost:61617?amqp.vhost=localhost]
So if the proper server to reconnect to is the original alternate on port 5673 then it won't ever try that one as the first broker told it that the only known brokers where the alternates it sent. You can change the client behaviour to not replace its original configuration of known hosts by setting the failover URI option below to either ADD or IGNORE.
failover.amqpOpenServerListAction Controls how the failover transport behaves when the connection Open frame from the remote peer provides a list of failover hosts to the client. This option accepts one of three values; REPLACE, ADD, or IGNORE (default is REPLACE). If REPLACE is configured then all failover URIs other than the one for the current server are replaced with those provided by the remote peer. If ADD is configured then the URIs provided by the remote are added to the existing set of failover URIs, with de-duplication. If IGNORE is configured then any updates from the remote are dropped and no changes are made to the set of failover URIs in use.
See the Qpid JMS client configuration page for more info.

Related

DefaultShutdownStrategy not working in apache camel

I have created a bean of DefaultShutdownStrategy in camel-context.xml file and was expecting that it will shutdown the routes gracefully. However, I am not seeing any DefaultShutdownStrategy related logging happening during shutdown of my apache camel application.
Last logs I could see is:
2022-12-05 02:43:49,424 DEBUG org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup signal, stopping the main instance.
Now I am not sure if DefaultShutdownStrategy is working or not for graceful shutdown of context.
I have enabled DEBUG log also for "org.apache.camel.impl" package in my log4j.xml
Can someone please help me in figuring out why my DefaultShutdownStrategy is not working ?
I tried creating bean of DefaultShutdownStrategy
Below is the bean definition of DefaultShutdownStrategy in my camel-context.xml
<bean id="fixShutdownStrategy" class="org.apache.camel.impl.engine.DefaultShutdownStrategy">
<constructor-arg name="camelContext" ref="camel"/>
<property name="timeout" value="240"/>
</bean>

Camel + Tomcat + Datasource + JNDI = Impossible

I have a Spring app that runs in Tomcat and connects okay to a JNDI configured datasource. I'm trying to get my Apache Camel app to do the same.
Tomcat context.xml
<ResourceLink global="jdbc/deapplication-datasource" name="jdbc/deapplication-datasource" type="javax.sql.DataSource"/>
Tomcat server.xml
<Resource name="jdbc/deapplication-datasource"
auth="Container"
type="javax.sql.DataSource"
maxTotal="50" maxIdle="30" maxWaitMillis="10000"
username="yada" password="nada"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#//test-cluster:1521/foo.bar.ca"/>
camel-config.xml
<!-- JNDI connection fails with Tomcat localhost (works in our testing/WebLogic environment -->
<bean id="dataSourceHello" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/deapplication-datasource"/>
</bean>
<!-- manual config works
<bean id="dataSourceHello" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:#//test-cluster:1521/foo.bar.ca" />
<property name="username" value="yada" />
<property name="password" value="nada" />
</bean>
-->
Java/Camel code:
from("direct:healthCheckDb")
.log("0")
.setBody(simple("select * from dual"))
.log("1")
.to("jdbc:dataSourceHello")
.log("2")
Tomcat log:
2022-06-13 12:07:49,879 INFO - 0
2022-06-13 12:07:49,881 INFO - 1
2022-06-13 12:07:50,444 ERROR - Failed delivery for (MessageId: ID-IT-DEV-VM-112-1655147269874-0-1 on ExchangeId: ID-IT-DEV-VM-112-1655147269874-0-1). On delivery attempt: 0 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-IT-DEV-VM-112-1655147269874-0-1]
2022-06-13 12:07:50,456 ERROR - null org.apache.camel.CamelExecutionException Exception occurred during execution on the exchange: Exchange[ID-IT-DEV-VM-112-1655147269874-0-1]
Tomcat and the app start up okay, but when I hit the restful path to test healthCheckDb it fails after log 1 but before log 2 (as you probably noticed above). The same statement works if I use the manual configured datasource. But I'd prefer to use the same setup as we use for WebLogic so I don't have to keep uncommenting and commenting the camel-config.xml file.
(Side note: after hours of research, have not seen 2 web pages agree on how to configure Tomcat JNDI for a datasource).
Possible to get Camel working with JNDI?

WFLYEE0007: Not installing optional component org.apache.cxf.transport.servlet.CXFServlet due to an exception

i want to deploy cxf-based application on wildfly17. i have not included external cxf library in war i want to use internal cxf of wildfly.?
server.log
2019-08-20 17:59:57,235 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-2) WFLYDM0111: Keystore C:\Users\kumarkun\Downloads\jars\wildfly\wildfly-16.0.0.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
2019-08-20 17:59:57,261 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\kumarkun\Downloads\jars\wildfly\wildfly-16.0.0.Final\standalone\deployments
2019-08-20 17:59:57,277 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "proj2.war" (runtime-name: "proj2.war")
2019-08-20 17:59:57,962 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
2019-08-20 17:59:58,058 INFO [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0493: EJB subsystem suspension complete
2019-08-20 17:59:58,192 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
2019-08-20 17:59:58,470 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
2019-08-20 17:59:58,658 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBossWS 5.2.4.Final (Apache CXF 3.2.7)
2019-08-20 17:59:59,641 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.apache.cxf.transport.servlet.CXFServlet due to an exception (enable DEBUG log level to see the cause)
2019-08-20 17:59:59,805 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.springframework.web.context.ContextLoaderListener due to an exception (enable DEBUG log level to see the cause)
2019-08-20 18:00:00,144 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Infinity Minus ONE +2' 9.4.8.Final
2019-08-20 18:00:00,191 INFO [org.jboss.ws.cxf.metadata] (MSC service thread 1-7) JBWS024061: Adding service endpoint metadata: id=com.services.Addition
address=http://localhost:8080/proj2/AdditionService
implementor=com.services.Addition
serviceName={http://services.com/}AdditionService
portName={http://services.com/}AdditionPort
annotationWsdlLocation=null
wsdlLocationOverride=null
mtomEnabled=false
2019-08-20 18:00:00,230 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."proj2.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."proj2.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "proj2.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:183)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1738)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1700)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1558)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.wsf.spi.WSFException: WFLYWS0066: Servlet class org.apache.cxf.transport.servlet.CXFServlet declared in web.xml; either provide a proper deployment relying on JBossWS or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. The former approach is recommended, as the latter approach causes most of the webservices Java EE and any JBossWS specific functionality to be disabled.
at org.jboss.as.webservices.tomcat.WebMetaDataModifier.configureEndpoints(WebMetaDataModifier.java:98)
at org.jboss.as.webservices.tomcat.WebMetaDataModifier.modify(WebMetaDataModifier.java:63)
at org.jboss.as.webservices.tomcat.WebMetaDataModifyingDeploymentAspect.start(WebMetaDataModifyingDeploymentAspect.java:40)
at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:73)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:176)
... 8 more
2019-08-20 18:00:00,739 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 74) WFLYCLINF0002: Started client-mappings cache from ejb container
2019-08-20 18:00:00,939 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "proj2.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"proj2.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"proj2.war\"
Caused by: org.jboss.wsf.spi.WSFException: WFLYWS0066: Servlet class org.apache.cxf.transport.servlet.CXFServlet declared in web.xml; either provide a proper deployment relying on JBossWS or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. The former approach is recommended, as the latter approach causes most of the webservices Java EE and any JBossWS specific functionality to be disabled."}}
2019-08-20 18:00:00,970 INFO [org.jboss.as.server] (ServerService Thread Pool -- 43) WFLYSRV0010: Deployed "proj2.war" (runtime-name : "proj2.war")
2019-08-20 18:00:00,973 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."proj2.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "proj2.war"
2019-08-20 18:00:01,153 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2019-08-20 18:00:01,157 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
2019-08-20 18:00:01,157 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
2019-08-20 18:00:01,158 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 16.0.0.Final (WildFly Core 8.0.0.Final) started (with errors) in 11390ms - Started 371 of 561 services (1 services failed or missing dependencies, 326 services are lazy, passive or on-demand)
i tried to few solution:
1) comment out:-
standalone.xml
<extension module="org.jboss.as.webservices"/>
<subsystem xmlns="urn:jboss:domain:webservices:2.0" statistics-enabled="${wildfly.webservices.statistics-enabled:${wildfly.statistics-enabled:false}}">
<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
<endpoint-config name="Standard-Endpoint-Config"/>
<endpoint-config name="Recording-Endpoint-Config">
<pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
<handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
</pre-handler-chain>
</endpoint-config>
<client-config name="Standard-Client-Config"/>
</subsystem>
2)
adding dependencies in MAINFIST.MF
Dependencies: org.apache.cxf services
Addition.java :-
#WebService(targetNamespace = "http://services.com/", portName = "AdditionPort", serviceName = "AdditionService")
public class Addition {
#WebMethod(operationName = "func1", action = "urn:Func1")
public int func1(#WebParam(name = "arg0") int x, #WebParam(name = "arg1") int y) {
return x+y;
}
}
web.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>proj1</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>Apache CXF Endpoint</description>
<display-name>cxf</display-name>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/cxf-beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
cxf-bean.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:endpoint xmlns:tns="http://services.com/"
id="addition" implementor="com.services.Addition"
wsdlLocation="wsdl/addition.wsdl" endpointName="tns:AdditionPort"
serviceName="tns:AdditionService" address="/AdditionPort">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" scope="singleton" />
</jaxws:features>
</jaxws:endpoint>
</beans>
applicationConext.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder properties-ref="deployProperties"/>
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config/>
<!-- Imports SpringMVC configuration -->
<import resource="cxf-beans.xml" />
</beans>
i expect to deploy cxf based applicaion on wildfly server using wildfly internal modules.

Excpetion while configuring camel jmx in jboss

I am deploying came jmxAgent in Jboss 6.3.0. Follwing is the code snippet:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd ">
<context:annotation-config />
<!-- start : Files import to camel context-->
<!-- Active MQ message broker -->
<!-- <import resource="classpath:META-INF/spring/message-borker/integration-message-broker.xml" /> -->
<import resource="file:${FIS_HOME}/COMMON/database-context.xml" />
<import resource="file:${FIS_HOME}/CA/job-scheduer-route-context.xml" />
<import resource="file:${FIS_HOME}/CA/jobs-process-route-context.xml" />
<import resource="file:${FIS_HOME}/CA/pci-jobs-process-route-context.xml" />
<import resource="file:${FIS_HOME}/CA/archiving_reports.xml" />
<import resource="file:${FIS_HOME}/COMMON/powercard-sqlFetcher-route-context.xml" />
<import resource="file:${FIS_HOME}/COMMON/rest/rest-context.xml" />
<!-- End : Files import to camel context-->
<camelContext xmlns="http://camel.apache.org/schema/spring" trace="true" streamCache="true"
lazyLoadTypeConverters="true" id="main">
<properties>
<property key="CamelLogEipName" value="com.hp.rcu.rtsp.filemanager.route"/>
</properties>
<propertyPlaceholder id="properties"
location="file:${FIS_HOME}/COMMON/routes.properties"
xmlns="http://camel.apache.org/schema/spring"/>
<jmxAgent id="agent" createConnector="true"/>
</camelContext>
An although the deployment is successful i am able to see the below exception in the logs:
13:50:47,163 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) Exception in thread "Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://205.239.212.91:1099/jmxrmi/camel" java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
13:50:47,164 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:155)
13:50:47,165 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.jboss.as.naming.WritableServiceBasedNamingStore.bind(WritableServiceBasedNamingStore.java:63)
13:50:47,165 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.jboss.as.naming.NamingContext.bind(NamingContext.java:248)
13:50:47,165 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.jboss.as.naming.InitialContext$DefaultInitialContext.bind(InitialContext.java:268)
13:50:47,167 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.jboss.as.naming.NamingContext.bind(NamingContext.java:257)
13:50:47,167 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at javax.naming.InitialContext.bind(InitialContext.java:425)
13:50:47,168 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at javax.naming.InitialContext.bind(InitialContext.java:425)
13:50:47,168 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:644)
13:50:47,168 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:427)
13:50:47,169 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at org.apache.camel.management.DefaultManagementAgent$1.run(DefaultManagementAgent.java:570)
13:50:47,170 ERROR [stderr] (Camel Thread #2 - Camel Thread #1 - JMXConnector: service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel) at java.lang.Thread.run(Thread.java:748)
Also I am not able to connect to the above url from jconsole.
Note: The jboss container is not in my local and in another server. So the JMX url is service:jmx:rmi:///jndi/rmi://uspnsvulx785.elabs.svcs.lxp.com:1099/jmxrmi/camel
Camel version: 2.23.2
You can check this - http://camel.apache.org/camel-jmx.html.
There is a section for JBoss here which will help you configure it.
Ok for now i have a workaround. Rather than implementing jmx connector in Camel, i have used the connector of Jboss itself. You can see all the mbeans of jboss within it. You will find all the mbeans of camel under org.apache.camel.
It will not fix the above exception but you can monitor camel routes and processors.
Also you can remove the jmxAgent line given below from the camel-context.xml if using the jboss connector.
<jmxAgent id="agent" createConnector="true"/>

cronscheduledroutepolicy not working as expected in switchyard

I am trying to implement cronscheduledroutepolicy in camel route and it is not working as expected. I am expecting switchyard Route to stop and start at cron trigger. I had added routePolicyRef="customRoutePolicy" and autoStartup="false" attributes in route definition.
logs:
23:07:01,530 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016009: Stopping weld service for deployment Thunderhead-POC-PDF-1.1-SNAPSHOT.jar
23:07:01,558 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Thunderhead-POC-PDF-1.1-SNAPSHOT.jar (runtime-name: Thunderhead-POC-PDF-1.1-SNAPSHOT.jar) in 30ms
23:07:01,559 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "Thunderhead-POC-PDF-1.1-SNAPSHOT.jar" (runtime-name: "Thunderhead-POC-PDF-1.1-SNAPSHOT.jar")
23:07:01,657 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016002: Processing weld deployment Thunderhead-POC-PDF-1.1-SNAPSHOT.jar
23:07:01,716 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: Thunderhead-POC-PDF-1.1-SNAPSHOT.jar
23:07:01,718 INFO [org.switchyard] (MSC service thread 1-4) Deploying SwitchYard application 'Thunderhead-POC-PDF-1.1-SNAPSHOT.jar'
23:07:01,720 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016008: Starting weld service for deployment Thunderhead-POC-PDF-1.1-SNAPSHOT.jar
23:07:01,764 INFO [org.switchyard] (MSC service thread 1-4) Starting SwitchYard service
23:07:01,768 INFO [org.apache.camel.management.ManagementStrategyFactory] (MSC service thread 1-4) JMX enabled.
23:07:01,771 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Apache Camel 1.1.1-p5-redhat-1 (CamelContext: camel-33) is starting
23:07:01,805 INFO [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-4) Loaded 181 type converters
23:07:01,814 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Total 0 routes, of which 0 is started.
23:07:01,814 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Apache Camel 1.1.1-p5-redhat-1 (CamelContext: camel-33) started in 0.043 seconds
23:07:01,967 INFO [org.quartz.simpl.SimpleThreadPool] (MSC service thread 1-4) Job execution threads will use class loader of thread: MSC service thread 1-4
23:07:01,978 INFO [org.quartz.core.SchedulerSignalerImpl] (MSC service thread 1-4) Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
23:07:01,979 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-4) Quartz Scheduler v.1.8.5 created.
23:07:01,979 INFO [org.quartz.simpl.RAMJobStore] (MSC service thread 1-4) RAMJobStore initialized.
23:07:01,980 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-4) Scheduler meta-data: Quartz Scheduler (v1.8.5) 'DefaultQuartzScheduler-camel-33' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
23:07:01,980 INFO [org.quartz.impl.StdSchedulerFactory] (MSC service thread 1-4) Quartz scheduler 'DefaultQuartzScheduler-camel-33' initialized from an externally provided properties instance.
23:07:01,980 INFO [org.quartz.impl.StdSchedulerFactory] (MSC service thread 1-4) Quartz scheduler version: 1.8.5
23:07:01,980 INFO [org.apache.camel.component.quartz.QuartzComponent] (MSC service thread 1-4) Starting Quartz scheduler: DefaultQuartzScheduler-camel-33
23:07:01,981 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-4) Scheduler DefaultQuartzScheduler-camel-33_$_NON_CLUSTERED started.
23:07:01,982 INFO [org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy] (MSC service thread 1-4) Scheduled trigger: triggerGroup-route19.trigger-START-route19 for action: START on route route19
23:07:02,001 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Skipping starting of route route19 as its configured with autoStartup=false
23:07:02,153 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Route: direct:{urn:com.example.switchyard:Thunderhead-POC-PDF:1.0}ESBService started and consuming from: Endpoint[direct://%7Burn:com.example.switchyard:Thunderhead-POC-PDF:1.0%7DESBService]
23:07:02,217 INFO [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Route: V1CamelJmsBindingModel/ESBService#jms1#-275801100 started and consuming from: Endpoint[jms://queue:Document.Eu.In.Deferred?connectionFactory=%23ConnectionFactory&replyTo=Document.Eu.Out.Result]
23:07:02,319 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018565: Replaced deployment "Thunderhead-POC-PDF-1.1-SNAPSHOT.jar" with deployment "Thunderhead-POC-PDF-1.1-SNAPSHOT.jar"
Iam trying similar to this Throttling based on time interval need to pick messages from queue only during cron trigger,but the attached component starts listening the queue once deployment is done.
can you please tell me what might be the issue?
Camel Route:
<?xml version="1.0" encoding="ASCII"?>
<routes xmlns="http://camel.apache.org/schema/spring">
<route streamCache="true" routePolicyRef="customRoutePolicy" autoStartup="false">
<from uri="switchyard://ESBService" />
<log message="Header is: ${headers.ResponseType}" />
<choice>
<when>
<simple>${headers.ResponseType} == 'XMLANDPDF'</simple>
<bean ref="CreateStub" method="setAttachmentInHeader()" />
<to uri="xslt:xslt/create-response.xslt" />
</when>
<otherwise>
<bean ref="CreateStub" method="setAttachmentInBody()" />
</otherwise>
</choice>
<log message="Response is: ${body}" />
</route>
</routes>
Route Policy:
package com.example.switchyard.Thunderhead_POC_PDF;
import javax.enterprise.inject.Produces;
import javax.inject.Named;
import org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy;
public class MyRoutePolicy{
#Produces #Named("customRoutePolicy")
public static CronScheduledRoutePolicy createRoutePolicy ()
{
CronScheduledRoutePolicy policy=new CronScheduledRoutePolicy();
policy.setRouteStartTime("0 27 18 ? * *");
policy.setRouteStopGracePeriod(10000);
policy.setRouteStartTime("0 29 18 ? * *");
return policy;
}
}
Switchyard xml:
<?xml version="1.0" encoding="UTF-8"?>
<sy:switchyard xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:jms="urn:switchyard-component-camel-jms:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sy="urn:switchyard-config:switchyard:1.1" name="Thunderhead-POC-PDF" targetNamespace="urn:com.example.switchyard:Thunderhead-POC-PDF:1.0">
<sca:composite name="Thunderhead-POC-PDF" targetNamespace="urn:com.example.switchyard:Thunderhead-POC-PDF:1.0">
<sca:component name="Component">
<camel:implementation.camel>
<camel:xml path="route.xml"/>
</camel:implementation.camel>
<sca:service name="ESBService">
<sy:interface.esb inputType="java.lang.String" outputType="java.io.InputStream"/>
</sca:service>
</sca:component>
<sca:service name="ESBService" promote="Component/ESBService">
<sy:interface.esb inputType="java.lang.String" outputType="java.io.InputStream"/>
<jms:binding.jms name="jms1">
<jms:contextMapper includes="sourceSystemID.*,ResponseType.*"/>
<jms:queue>Document.Eu.In.Deferred</jms:queue>
<jms:connectionFactory>#ConnectionFactory</jms:connectionFactory>
<jms:replyTo>Document.Eu.Out.Result</jms:replyTo>
</jms:binding.jms>
</sca:service>
</sca:composite>
</sy:switchyard>

Resources