No reply received - perhaps a timeout in the template? - spring-amqp

I have done following RabbitMQ-Spring configuration for RPC call
Following is the configuration:-
/>
<rabbit:queue name="identity.queue" />
<rabbit:direct-exchange name="identity.exchange">
<rabbit:bindings>
<rabbit:binding queue="identity.queue" key="identity.binding"/>
</rabbit:bindings>
</rabbit:direct-exchange>
<bean id="idenityListener"
class="org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter">
<property name="serviceInterface" value="<<package>.AA" />
<property name="service" ref="AAProxy" />
<property name="amqpTemplate" ref="template" />
</bean>
<rabbit:listener-container connection-factory="connectionFactory">
<rabbit:listener ref="idenityListener" queue-names="identity.queue" />
</rabbit:listener-container>
At client side:-
/>
<bean id="identityClient"
class="org.springframework.amqp.remoting.client.AmqpProxyFactoryBean">
<property name="amqpTemplate" ref="identityTemplate" />
<property name="serviceInterface" value="<<package>.AA" />
</bean>
<bean id="AAProxy" class="<xx>.AAProxy" init-method="init" />
<rabbit:template id="identityTemplate" connection-factory="connectionFactory" reply-timeout="2000"
routing-key="identity.binding" exchange="identity.exchange" />
I am getting the following error while setup for RabbitMQ RPC call. This setup working on same machine and while not working on different machine:-
Caused by: org.springframework.remoting.RemoteProxyFailureException: No reply received - perhaps a timeout in the template?
at org.springframework.amqp.remoting.client.AmqpClientInterceptor.invoke(AmqpClientInterceptor.java:60)
**Log file:-**
=ERROR REPORT==== 19-Feb-2015::10:05:59 ===
Channel error on connection <0.1474.0> (172.16.206.139:59826 -> 172.16.206.154:5672, vhost: '/', user: 'reetesh'), channel 13:
{amqp_error,not_found,"no queue 'identity.queue' in vhost '/'",
'queue.declare'}
Whenever I tried to connect I found following above in log.
Reetesh

i had a similar problem, i not fix them. Finally i use "direct reply-to"
See
http://docs.spring.io/spring-amqp/docs/1.4.3.BUILD-SNAPSHOT/reference/html/amqp.html
3.7.1 section.
with this configuration not needs a fixed reply queue and "reply-listener" is not required and should not be configured.

Related

Malformed url on SEND mediator

Scenario:
I'm using the WSO2 EI 6.4.0. ESB to convert an incoming SOAP message to JSON and sending it out to our internal applications REST service.
Currently I'm using an inbound endpoint to handle the SOAP request (although I've tried Proxy service which gives me the same result). The incoming message is successfully received, the conversion seems fine as well, but the call to the internal rest is failing. For some reason, the ESB handles all the requests to this rest interface as follows:
/http:/InternalApp:8000/rest/xml_messages/iend_incoming
Notice that the actual URL that I provide in the SEND mediator is as follows:
http://InternalApp:8000/rest/xml_messages/
The last piece of the incorrect url (i.e. iend_incoming) is actually the name of the inbound endpoint on the ESB itself. I'm pretty confused as to how this ended up but it looks as though the ESB is considering this to be some sort of proxy call.
The following code is used on the ESB in the sequence tied to aforementioned inbound endpoint:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="seq_send_soap_to_rest" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>
<property name="FORCE_HTTP_1.0" scope="axis2" type="STRING" value="true"/>
<payloadFactory media-type="json">
<format>
{
"xml_content": "$1",
"sender": "$2",
"receiver": "$3"
}
</format>
<args>
<arg evaluator="xml" expression="base64Encode($env)"/>
<arg evaluator="xml" expression="$body//cac:ConsigneeParty/cac:PartyIdentification/cbc:ID" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"/>
<arg evaluator="xml" expression="$body//cac:ConsignorParty/cac:PartyIdentification/cbc:ID" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"/>
</args>
</payloadFactory>
<property expression="fn:concat('Basic ', base64Encode('USRNAME:PWD'))" name="Proxy-Authorization" scope="transport" type="STRING"/>
<property name="POST_TO_URI" scope="axis2" type="STRING" value="true"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<send>
<endpoint>
<address format="rest" uri="http://InternalApp:8000/rest/xml_messages/"/>
</endpoint>
</send>
</sequence>
Does anyone have any clue as to how that malformed URL ended up there and how I can fix it?
Apparently, it was this line:
<property name="POST_TO_URI" scope="axis2" type="STRING" value="true"/>
Setting it to false gave me a bad request but at least I knew where to look. The name of the variable might be a bit misleading.

Using spring-rabbit, spring-amqp. How to collect rabbitMQ metrics inside client machine

On client machine, I am using spring-rabbit-1.6.7.RELEASE.jar and spring-amqp-1.6.7.RELEASE.jar to perform operations on RabbitMQ.
Now, need is to monitor the metrics like # of open channels, # of rejected messages etc from given client machine to RabbitMQ server.
www.rabbitmq.com/monitoring.html mentions that some client libraries and frameworks provide means of registering metrics collectors or collect metrics out of the box. RabbitMQ Java client and Spring AMQP are two examples.
Please suggest how I can use Spring AMQP to collect metrics with respect to given client machine to RabbitMQ server.
Please note I am using org.springframework.amqp.rabbit.connection.CachingConnectionFactory. But it doesn't have any method to set metric collector..
We are using xml with following tags to define connection factory, queue, binding etc.
Rabbit:Queues , Rabbit:queue-arguments , • Rabbit:DIRECTExchange , Rabbit:TOPICExchange, Rabbit:binding , Rabbit:Admin [[[ ConnectionFactory]]]
e.g.
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg value="#{messagingProperties['mq.hostname']}" />
<property name="virtualHost" value="#{messagingProperties['mq.virtual-host']}" />
<property name="username" value="#{messagingProperties['mq.username']}" />
<property name="password" value="#{messagingProperties['mq.password']}" />
<property name="channelCacheSize" value="25" />
</bean>
1.6.7 is extremely old; you should upgrade to at least 1.7.14; the current version is 2.1.8.
You can set the metricsCollector on the underlying rabbit connection factory.
connectionFactory.getRabbitConnectionFactory().setMetricsCollector(...);
Or use the RabbitConnectionFactoryBean to create the underlying connection factory, and then inject it into the CachingConnectionFactory.
<bean id="rcf" class= "...RabbitConnectionFactoryBean">
... set all the properties here
</bean>
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg ref="rcf" />
<property name="channelCacheSize" value="25" />
</bean>

Read time out spring web services

I am using spring web services framework to call some SOAP apis.
My configuration is like this:
<bean name="wsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate" scope="prototype" >
<constructor-arg ref="messageFactory" />
<property name="marshaller" ref="marshaller"/>
<property name="unmarshaller" ref="unmarshaller"/>
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"/>
</property>
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
<property name="contextPaths">
<list>
some configured classes here
</list>
</property>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
<property name="contextPaths">
<list>
some configured classes here
</list>
</property>
</bean>
Note I am using a prototype scope. I am not sure if that could be causing issues.
In my java code I use WebServiceTemplate like this:
#PostConstruct
private void init() {
try {
String uri = "https://web/file.svc?wsdl"
webServiceTemplate.setDefaultUri(uri);
} catch (Exception exception) {
logger.error("Error creating URL for the wsdl location.", exception);
}
}
I call the webservice like this:
Response response = (Response) webServiceTemplate.marshalSendAndReceive(request, new SoapActionCallback(SOAP_ACTION_URL));
I am getting the following read time out exception which I am not sure what it is, I have read it is because the response it is too big, but it really is not. It is not bigger than 100K
org.springframework.ws.client.WebServiceIOException: I/O error: Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out
15:27:49,028 INFO [stdout] (default task-22) at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561) ~[spring-ws-core-2.2.4.RELEASE.jar:2.2.4.RELEASE]
15:27:49,028 INFO [stdout] (default task-22) at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-2.2.4.RELEASE.jar:2.2.4.RELEASE]
15:27:49,028 INFO [stdout] (default task-22) at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383) ~[spring-ws-core-2.2.4.RELEASE.jar:2.2.4.RELEASE]
What could be the issue ? I am clueless
At the end, I am not sure what was the issue, but I solved it by setting the message sender to a diferent provider . I set it to some apache library
<bean name="wsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate" scope="prototype" >
<constructor-arg ref="messageFactory" />
<property name="marshaller" ref="marshaller"/>
<property name="unmarshaller" ref="unmarshaller"/>
<property name="messageSender">
<bean class="org.springframework.ws.transport.http.HttpComponentsMessageSender" />
</property>
</bean>

Having trouble getting Camel to use JDNI for database connection

I am having trouble getting Camel to work with jndi. I am deploying camel inside of IBM Websphere.
Inside of Websphere there is a jdni connection called "vzw.ds.commerce" that is setup to connect to the database I want to access.
This route below works:
<bean class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" id="publishDB">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:#//server.com:2051/mbschema" />
<property name="username" value="username" />
<property name="password" value="password" />
</bean>
<bean id="commerceDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="vzw.ds.commerce" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="timer-to-console" customId="true">
<from uri="timer://foo?fixedRate=true&period=10s" />
<transform>
<simple>30004</simple>
</transform>
<process ref="createSQL" />
<to uri="jdbc:publishDB" />
<process ref="processSQL" />
<to uri="stream:out" />
</route>
</camelContext>
However, I want to use the jndi connection and not have the connection information in the route.
When I change the line to:
I get the error:
java.sql.SQLException: invalid arguments in call DSRA0010E: SQL State = null, Error Code = 17,433
The code I posted actually was correct. The problem I had was with the setup on Websphere.
Once I changed the setting on Websphere the code started working.

can I define the activemq admin console url?

Activemq's admin console, as standard, points to 0.0.0.0:8161.
I know I can change the port from 8161 in the jetty.xml config file.
Is it possible to change the URL from 0.0.0.0?
The answer was pretty obvious. In jetty.xml:
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8161" />
<property name="host" value="HOSTNAME" />
</bean>

Resources