Why in camel-rabbitmq component RabbitMq connectionFactory must be specified. I am getting exception if I dont specify the connection factory bean? - rabbitmq

I am working on the camel-rabbitmq component. If I dont specify the connectionFactory bean I am getting error
java.net.BindException:Cannot assign requested address: connect
at sun.nio.ch.Net.connect0(Native Method) ~[?:?]
at sun.nio.ch.Net.connect(Net.java:579) ~[?:?]
at sun.nio.ch.Net.connect(Net.java:568) ~[?:?]
at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588) ~[?:?]
But with camel-activemq even if I don't specify the connectionFactory bean it is working because it's creating the default connectionFactory object itself? But why it is not happenning in case of camel-rabbitmq component. I want to know the reason behind it. Thank you in advance.

Related

Ignite throws SocketTimeoutException randomly while running in PROD

It throws below error and restarts thereafter without printing much logs.
TcpDiscoverySpi [tcp-disco-sock-reader-[]-#13-#76] Failed to initialize connection (this can happen due to short time network problems and can be ignored if does not affect node discovery) [sock=Socket[addr=/10.178.19.121,port=45450,localport=18036]]
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[?:?]
at java.net.SocketInputStream.socketRead(SocketInputStream.java:115) ~[?:?]
at java.net.SocketInputStream.read(SocketInputStream.java:168) ~[?:?]
at java.net.SocketInputStream.read(SocketInputStream.java:140) ~[?:?]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:252) ~[?:?]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:292) ~[?:?]
at java.io.BufferedInputStream.read(BufferedInputStream.java:351) ~[?:?]
at org.apache.ignite.spi.discovery.tcp.ServerImpl$SocketReader.body(ServerImpl.java:6784) ~[ignite-core-2.10.0.jar!/:2.10.0]
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:58) ~[ignite-core-2.10.0.jar!/:2.10.0]
What could be the potential reason for this error and how to prevent Ignite from throwing this error?

Getting jmeter error: java.net.UnknownHostException: This is usually a temporary error during hostname resolution

I am a beginner to jmeter. I am trying to perform a simple load test using jmeter 4.0. I created a HTTP sampler and added a view results tree listener.
HTTP Sampler
But getting the below error under Response data in results tree.
"java.net.UnknownHostException: This is usually a temporary error during hostname resolution and means that the local server did not
receive a response from an authoritative server at
java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at
java.net.InetAddress$2.lookupAllHostAddr(Unknown Source) at
java.net.InetAddress.getAddressesFromNameService(Unknown Source) at
java.net.InetAddress.getAllByName0(Unknown Source) at
java.net.InetAddress.getAllByName(Unknown Source) at
java.net.InetAddress.getAllByName(Unknown Source) at
org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at
org.apache.jmeter.protocol.http.sampler.hc.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:318)
at
org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:114)
at
org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
at
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:697)
at
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:455)
at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189)
at
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178)
at
org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490)
at
org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250)
at java.lang.Thread.run(Unknown Source)"
All requests are getting failed. There is no problem in internet connectivity. Please resolve my issue.
I just faced same issue. Found solution using below steps:
1.
Protocol:http/https
server name/IP:google.com
port & path:blank(as no params)
add proxy details if required

Why isn't my connection working over SSL?

I am trying to use apache camel (camel-spring-boot - 2.20.2) with rabbitmq and create routes.
It does work fine when I use un-secured RabbitMQ (no-SSL), but when I try to connect to RabbitMQ using SSL, it's not connecting to the queue at all.
I am using "connectionFactory" option given on Apache Camel page. This connectionFactory object has all the correct parameters set (useSslProtocol, username, password etc).
Please note that the connectionFactory is properly populated, as I am able to use it to connect using the other way (setting it in setConnectionFactory on SimpleMessageListenerContainer). But with Apache Camel I am facing issues.
java.io.IOException: null
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:116) ~[amqp-client-4.1.0.jar!/:4.1.0]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:112) ~[amqp-client-4.1.0.jar!/:4.1.0]
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:360)
~[amqp-client-4.1.0.jar!/:4.1.0]
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
~[amqp-client-4.1.0.jar!/:4.1.0]
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
~[amqp-client-4.1.0.jar!/:4.1.0]
*
*
Caused by: java.io.EOFException
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290)
~[?:1.8.0_161]
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-4.1.0.jar!/:4.1.0]
While browsing more, I came across this question:
Apache Camel SSL RabbitMQ, but this seems to be a bit old, so may not be relevant anymore.
Please advise. This has become a show-stopper for us.
I made some changes… I realized that I was not using the connectionFactory in the URL correctly -
Followed this link - How to set two RabbitMQ connections for the same Camel RouteBuilder configure method and could move ahead…. But now, I am getting this ( looks like I made some progress, but still facing the below ).
java.net.ConnectException: Connection refused (Connection refused) at
java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:1.8.0_161]
at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
~[?:1.8.0_161] at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
~[?:1.8.0_161] at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
~[?:1.8.0_161] at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
~[?:1.8.0_161] at java.net.Socket.connect(Socket.java:589)
~[?:1.8.0_161] at
sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:673)
~[?:1.8.0_161] at
com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:50)
~[amqp-client-4.1.0.jar!/:4.1.0] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:918)
~[amqp-client-4.1.0.jar!/:4.1.0] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:870)
~[amqp-client-4.1.0.jar!/:4.1.0] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:828)
~[amqp-client-4.1.0.jar!/:4.1.0] at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:996)
~[amqp-client-4.1.0.jar!/:4.1.0] at
org.apache.camel.component.rabbitmq.RabbitMQEndpoint.connect(RabbitMQEndpoint.java:248)
~[camel-rabbitmq-2.20.2.jar!/:2.20.2] at
org.apache.camel.component.rabbitmq.RabbitMQConsumer.openConnection(RabbitMQConsumer.java:64)
~[camel-rabbitmq-2.20.2.jar!/:2.20.2] at
org.apache.camel.component.rabbitmq.RabbitMQConsumer.getConnection(RabbitMQConsumer.java:75)
~[camel-rabbitmq-2.20.2.jar!/:2.20.2] at
org.apache.camel.component.rabbitmq.RabbitConsumer.(RabbitConsumer.java:55)
[camel-rabbitmq-2.20.2.jar!/:2.20.2] at
org.apache.camel.component.rabbitmq.RabbitMQConsumer.createConsumer(RabbitMQConsumer.java:120)
[camel-rabbitmq-2.20.2.jar!/:2.20.2]
Route looks like below -
connectionFactory object is populated correctly. Its being used in the application and working ( uses regular Spring way of connecting to RabbitMQ )
final CamelContext camelContext = getContext(); final
org.apache.camel.impl.SimpleRegistry registry = new
org.apache.camel.impl.SimpleRegistry(); final
org.apache.camel.impl.CompositeRegistry compositeRegistry = new
org.apache.camel.impl.CompositeRegistry();
compositeRegistry.addRegistry(camelContext.getRegistry());
compositeRegistry.addRegistry(registry);
((org.apache.camel.impl.DefaultCamelContext)
camelContext).setRegistry(compositeRegistry);
registry.put("connectionFactoryWorker", connectionFactory);
from("rabbitmq::5671/?queue=&connectionFactory=#connectionFactoryWorker").log("received
message");

Error when setting 'maxThreadsActive' on anypoint MQ

I am trying to set "maxThreadsActive" to 1 , to make sure there is only one thread pulling messages form queue , but for some reason i am getting sax parse exception in compile time .
Following is the Configuration :
<anypoint-mq:config name="Anypoint_MQ_Configuration"
provider-ref="anypointMQ_Provider_Settings" doc:name="Anypoint MQ Configuration" >
<http:worker-threading-profile maxThreadsActive="1"/>
</anypoint-mq:config>
error :
ERROR 2017-10-04 12:35:00,849 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'http:worker-threading-profile'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/tls":context, "http://www.mulesoft.org/schema/mule/http":proxy, "http://www.mulesoft.org/schema/mule/anypoint-mq":provider, "http://www.mulesoft.org/schema/mule/anypoint-mq":prefetch, "http://www.mulesoft.org/schema/mule/anypoint-mq":worker-threading-profile}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[?:?]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) ~[?:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[?:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[?:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[?:?]
The issue is with the Anypoint Studio.
The anypoint-mq connector configuration from Studio creates a internal tag with http:worker-threading-profile, which is not a valid child element for the anypoint-mq:config element.
To fix the error, you need to manually update the XML file by removing the http:worker-threading-profile, and add the following child element 'anypoint-mq:worker-threading-profile'. If you add this element, then it would not be shown in the Studio, but it will set the Thread profiling to Anypoint MQ connector.
This is an error with Studio.
Please refer the following link and go to section 'Threading Profile Settings'
https://docs.mulesoft.com/mule-user-guide/v/3.9/anypoint-mq-connector-reference
It seems you may be missing some configurations, do check the following SO answer : https://stackoverflow.com/a/37904111/7141847
And if you are setting maxThreadsActive to 1 i believe you need to set poolExhaustedAction="WAIT" in anypoint-mq-configurations
I have faced the similar issue.To ressolve this we need to use updated anypoint mq connector for the AnypointStudio-version(6.6.0).
Studio & Mq version

Remote connection to Active-MQ Using JMX

I have a java application for monitoring the individual queues on Active MQ (version 5.13.0). The Objective of this application is to connect to the Active MQ broker and find out the in flight message count for specific queues. If the in flight message count is more than 50 then it sends an alert. This application performs this check every 10 minutes (Using Quartz Scheduler).
When I am connecting to the AMQ broker which uses the IP address to connect to the AMQ, I receive the IOException with the following stack trace -
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(Unknown Source)
at javax.management.remote.rmi.RMIConnector.connect(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at com.globalcharge.quartz.job.CheckPendingConsumer.execute(CheckPendingConsumer.java:51)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 12 more
I am using the following code to connect to the AMQ broker over JMX
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://192.168.11.72:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxc.getMBeanServerConnection();
ObjectName activeMq = new ObjectName("org.apache.activemq:Type=Broker,BrokerName=localhost");
BrokerViewMBean mbean = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(conn, activeMq, BrokerViewMBean.class, true);
//for each queue
for(ObjectName name : mbean.getQueues())
{
if(("dbg.notmanager.netsizeDelivery".equals(name)))
{
//obtain an instance of QueueViewMBean
QueueViewMBean queueMbean = (QueueViewMBean)MBeanServerInvocationHandler.newProxyInstance(conn, name, QueueViewMBean.class, true);
long inFlight = queueMbean.getInFlightCount();
if(inFlight >= 50)
{
sender.sendPassiveCriticalAlert(hostname, "Passive.GCDBG", "InFlight Messages for a consumer on " + name);
}
}
Notes:
1. If I install the AMQ on my local machine and deploy the code above on Tomcat running on my local machine it works. What I mean is, when both (Java Client and AMQ ) are on same machine, it works.
2. I have done the necessary configurations on AMQ server as mentioned here configure JMX for ActiveMQ for remoting access
3. I have checked the connectivity to IP and port mentioned in the code through telnet and it works.
4. I have also recorded the TCP dump on the AMQ server machine and I can see the request reaching there.
5. Both machines (where Tomcat and AMQ run) are not virtual machines, but are dedicated physical machines in the same network.
Please help :)
as logs say Connection refused, i think connection configs error.
you need these credentials too
JMXServiceURL url = ...;
Map env = ...;
String[] creds = {"admin", "activemq"};
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
I am able to connect now using the JConsole as well as the Java Code I have written. The Problem was in the env file (under amqHome/bin/) had a property java.rmi.server.hostname which had a value 127.0.0.1
I changed this value to 192.168.11.72 (the IP of the machine) and it worked ....
Thanks all for the support ....