I am using apache CXF implementation of JAX-WS.
My web service is configured via spring xml configuration using JaxWsProxyFactoryBean:
<bean id="myWSClient" class="my.package.MyWSClient"
factory-bean="clientFactory"
factory-method="create" />
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="my.package.MyWSClient"/>
<property name="address" value="http://some.url"/>
</bean>
and later I am injecting it via:
#Resource(name = "myWSClient")
MyWSClient myWSClient;
How I can manage to increase timeout for MyWSClient?
To configure client timeouts using spring configuration use this:
<http-conf:conduit name="*.http-conduit">
<http-conf:client
ConnectionTimeout="600000"
ReceiveTimeout="600000"/>
</http-conf:conduit>
In this example timeout for response and connection is setup for 600 seconds.
Reference:
Apache CXF: Client HTTP Transport: Advanced configuration
Related
We are implementing XA transaction between MQ and database and trying to create a connection factory as a service in karaf as per the below link.
https://access.redhat.com/documentation/fr-fr/red_hat_fuse/7.2/html/apache_karaf_transaction_guide/using-jms-connection-factories#manual-deployment-connection-factories
The MQ we are using is IBM and we are connecting to it through camel.
The karaf service is exposed from the same bundle that is going to use it. This is done through blueprint xml file present in the src/main/resources/OSGI-INF/blueprint folder.
When we use (through JNDI) the connection factory exposed as a service for setting the connection factory to be used by the JmsComponent of camel, we are able to get message from the queue but not able to put message into the queue. There is no error when the put operation fails and hence, the database gets updated with success. This happens specifically when using JmsPoolXAConnectionFactory as the pool connection factory. If we change it to JmsPoolConnectionFactory, the put operation works and the message is added to the queue.
Below are the sample routes for get and put to queue.
GET:
from("mq:queue:{{queueName}}")
.process(new CustomProcessor1())
.to("direct:call-sp")
.end();
from("direct:call-sp")
.to("sql-stored:call-sp")
.end();
PUT:
from("vm:send")
.process(new CustomProcessor2())
.to("mq:queue:{{queueName}}")
.to("sql-stored:update-sp")
.to("vm:nextroute")
.end();
Camel JmsComponent Configuration in camel-context.xml:
<reference id="ptm" interface="org.springframework.transaction.PlatformTransactionManager" />
<reference id="connectionFactory" interface="javax.jms.ConnectionFactory" filter="(osgi.jndi.service.name=jms/mq)" availability="optional" />
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="transacted" value="false" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="transactionManager" ref="ptm" />
</bean>
<bean id="mq" class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="jmsConfig" />
<property name="destinationResolver" ref="customDestinationResolver" />
</bean>
<bean id="customDestinationResolver" class="com.example.CustomDestinationResolver">
</bean>
Is there any put related specific configuration that we are missing?
To coordinate XA transactions, you need a transaction manager which implements the Java Transaction API (JTA).
Therefore, I think you need to use a JtaTransactionManager rather than a org.springframework.transaction.PlatformTransactionManager.
Check this out:
https://tomd.xyz/camel-xa-transactions-checklist/
While integrating to a TCP endpoint, we created an application using Spring integration TCP where we've a pooled connection using the following beans:
<!-- Pooled Connection factory -->
<int-ip:tcp-connection-factory id="client" type="client" host="${gateway.url}" port="${gateway.port}"
single-use="true" so-timeout="${gateway.socket.timeout}" serializer="appSerializerDeserializer" deserializer="appSerializerDeserializer" />
<bean id="cachedClient" class="org.springframework.integration.ip.tcp.connection.CachingClientConnectionFactory">
<constructor-arg ref="client" />
<constructor-arg value="${gateway.pool.size}" />
</bean>
Does anyone have a suggestion on how to implement a socket re-connection in case a socket loses the connection?
It will automatically reconnect the next time you send something.
I'm using camel. This is (an extract of) my blueprint:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<cm:property-placeholder id="placeholder" persistent-id="com.adelco.articulos" />
<!-- Configures the Inbound and Outbound SAP Connections -->
<bean id="sap-configuration" class="org.fusesource.camel.component.sap.SapConnectionConfiguration">
.
.
</bean>
<!--A lot of things here, let's omit them-->
<!-- Route beans-->
<bean id="rutaSTEPEntrada" class="com.adelco.articulos.RutaSTEPEntrada"/>
<bean id="rutaSTEPSap" class="com.adelco.articulos.RutaSTEPSap"/>
<camelContext id="camel-articulos" xmlns="http://camel.apache.org/schema/blueprint">
<routeBuilder ref="rutaSTEPEntrada"/>
<routeBuilder ref="rutaSTEPSap"/>
</camelContext>
</blueprint>
I want "disable" the bean "sap-configuration" but without using XML comments. Something like this:
<bean id="sap-configuration" enabled=${ENABLED} class="org.fusesource.camel.component.sap.SapConnectionConfiguration">
.
.
</bean>
I can define the camel routes I want to activate using "autoStartup" and property placeholders "autoStartup=${ENABLED}" but I can't find how to do this with the bean.
This is not possible. Its how OSGi blueprint works. If you define a <bean> then its in use.
I've referred to the JMS page of the Camel documentation and many related SO questions such as this one, but I'm unable to find a comprehensive list on the implementation.
I'm using Spring XML along with Camel and Weblogic for the server. I've made a test queue with the following names:
Server: TestJMSServer, Module: TestJMSModule, Queue: TestJMSQueue, CF: TestConnectionFactory.
According to the Camel documentation, my route should look something like this:
<camel:route id="test">
<camel:from uri="jms:TestJMSQueue" />
<camel:to uri="file:/Users/...." />
</camel:route>
This gives me an error saying "connectionFactory must be specified". So exactly what else do I need to add to my applicationContext.xml in order to listen to this queue?
You need to tell Camel's jms-component which JMS connection factory to use. Most likely you'll get that from jndi if you're using WebLogic.
In the example below i am looking up the connection factory using spring's jee:jndi-lookup (i believe that might even be a name you can use in WebLogic). The looked up factory is then made available as a spring bean with id myConnectionFactory.
This connection factory bean is then used for the connectionFactory property for camel's JmsComponent. Notice the id attribute: jms. This defines the camel endpoint uri scheme to be used in your routes.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
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">
<jee:jndi-lookup id="myConnectionFactory" jndi-name="jms/connectionFactory"/>
<route id="test" xmlns="http://camel.apache.org/schema/spring">
<from uri="jms:TestJMSQueue"/>
<to uri="file:/Users/...."/>
</route>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="myConnectionFactory"/>
<!-- more configuration required based on your requirements -->
</bean>
<!--
example uses invm amq broker:
<bean id="anothercnf" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://mybroker"/>
</bean>
-->
</beans>
Important Note: You will need to tune this further (setup transactions, setup concurrent consumers, possible configure a spring jms connection pool)
I have 2 docker containers, one running a spring app (in tomcat) and one running an active mq instance. When I try to connect to it from my spring app, I get the following error. Only activeMQ is running on the one container and the port is properly exposed. I verified the IP address of the docker container (shown below) and that is correct.
I'm not sure what could be causing this error at this point. Any thoughts would be appreciated.
ERROR [activemq.broker.BrokerService] Failed to start Apache ActiveMQ ([mybroker, ID:489af431756c-60313-1409695404227-0:1], java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://172.17.0.2:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Cannot assign requested address)
You configured Spring to start a broker service on 172.17.0.2, which is the IP of the remote machine. Instead, you should configure Spring to connect to an existing broker on that machine. From the ActiveMQ documentation and using the Spring facility JMSTemplate:
<!-- a pooling based JMS provider -->
<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://activemq-host.local:61616</value>
</property>
</bean>
</property>
</bean>
<!-- Spring JMS Template -->
<bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref local="jmsFactory"/>
</property>
</bean>