I have want to connect 2 micro services java with c#, in my c# I have setup my rabbitmq and I am running my services on docker. I believe everything is setup correctly but when trying to send over a message I get an error telling me my event bus does not exist. Even though i can see that the event bus does infact exist on the rabbitmq localhost website.
Would anyone know what causes this and how i could fix this, thank you for your time and help.
my rabbitmq port:
"15672:15672"
"5672:5672"
I can go on my localhost:15672 and see my exchanges and queues on rabbitmq
Yet when I try to use the "ConvertAndSend" Methode in java I get this error:
2022-08-30 12:01:47.801 INFO 90768 --- [nio-8090-exec-1] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2022-08-30 12:01:48.100 INFO 90768 --- [nio-8090-exec-1] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#1a1cc163:0/SimpleConnection#39d3d67d [delegate=amqp://guest#127.0.0.1:5672/, localP
ort= 56701]
2022-08-30 12:01:48.249 ERROR 90768 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'StudyP
lannerAndMonitor_event_bus' in vhost '/', class-id=60, method-id=40)
I have also let a friend try and run my code and he does not have the issue, everything seems to work fine with him.
Related
how to create a service(amqp) and ingress resource in k8s other than http or https?
We have a requirement where our java-spring-bot app needs to send request through 443/80 port and we are requirement to receive that request on port 443/80 & redirect it to our rabbitmq pods which runs on amqp protocol not on http/https.
I don't know as of now it's possible or not, but we have created ingress resource with which to redirect request to our rabbitmq deployment/pods.
Here's ingress resource definition.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ing-rabbitmq-amqp
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- path: /amqp
pathType: Prefix
backend:
service:
name: rabbitmq-amqp
port:
number: 5671
But we are making our java app connect to rabbitmq through this configuration we are getting error messages.
From our java-app
2023-02-03 07:13:51.031 INFO 1 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2023-02-03 07:13:51.106 INFO 1 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [10.25.119.247/amqp:80]
2023-02-03 07:13:51.125 INFO 1 --- [ main] o.s.a.r.l.SimpleMessageListenerContainer : Broker not available; cannot force queue declarations during start: java.net.UnknownHostException: 10.25.119.247/amqp
Usually our app throws this messages for successful connection with rabbitmq on port 5671
2023-02-03 07:15:44.087 INFO 1 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2023-02-03 07:15:44.150 INFO 1 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [10.25.119.247:5671]
2023-02-03 07:15:46.182 INFO 1 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#2f01783a:0/SimpleConnection#5b202a3a [delegate=amqp://test_bot_user#10.25.119.247:5671/test, localPort= 58840]
While nginx-ingress-controller pod is throwing below error messages.
2023/02/03 07:20:08 [error] 4299#4299: *209766772 recv() failed (104: Connection reset by peer) while proxying and reading from upstream, client: 10.25.119.247, server: 0.0.0.0:5671, upstream: "192.168.52.60:5671", bytes from/to client:5467/6570, bytes from/to upstream:6570/5467
[5.161.119.202] [03/Feb/2023:07:20:08 +0000] TCP 200 6570 5467 263.959
This is our serverIP: 10.25.119.247
This is rabbitmq-pod IP which is coming in that log: 192.168.52.60
So first of all is it possible to create k8s service and ingress resource on other protocols like amqp?
Secondly if answer to first question is No, we can't create those resources in k8s on protocols http/https and even if we can create but I cannot achieve this scenario then
how do I achieve my scenario where our client is behind a proxy(Cisco-WSA/12.5.2-007) wants our java-springboot app(which connects with rabbitmq on amqp protocol) to connect with our rabbitmq-pods through https ports only and is not willing to open rabbitmq tls port 5671 in his outbound request?
If any queries are there please me know?
i think it won't be possible with Nginx ingress just like that, as it supports the HTTP protocol.
Nginx ingress controller doc
although amqp uses the TCP as transport protocol implementing tcp_passthrough config on Nginx ingress controller might could be successful for you.
Update:
Ingress does not support TCP or UDP services. For this reason this
Ingress controller uses the flags --tcp-services-configmap
So you can expose one port on the ingress controller and use it to access the TCP service.
Create configmap in ingress-nginx namespace
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
5672: "default/rabbitmq-service:5672"
update nginx deployment with arg as it is without changing anything
--tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
and last, add port config in the deployment of nginx ingress as shown in the doc.
https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/
ERROR org.apache.activemq.broker.BrokerService - Failed to start Apache ActiveMQ ([localhost, null], java.io.IOException: org/apache/activemq/store/NoLocalSubscriptionAware)
INFO org.apache.activemq.broker.BrokerService - Apache ActiveMQ 5.9.1 (localhost, null) is shutting down
INFO org.apache.activemq.broker.TransportConnector - Connector tcp://localhost:61616 stopped
WARN org.apache.activemq.broker.jmx.ManagementContext - Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create JMX connector, trying to remedy this issue.
The code I am trying to use is
BrokerService broker = new BrokerService();
TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:61616"));
broker.addConnector(connector);
broker.start();
I am getting exception at start() method. I am deploying this on server not in my computer.
It's quite hard to say what is wrong given the limited information but one thing I'd check is that there isn't already a broker running on that server as it looks like something is at least sitting on the JMX port already. You could check in the broker log to see if the broker logs any additional information on the error.
My RabbitMQ server is running perfectly. Check below for ports and ip.
C:\Users\parmarc>netstat -ano | find "5672"
TCP 0.0.0.0:5672 0.0.0.0:0 LISTENING 2704
TCP 0.0.0.0:15672 0.0.0.0:0 LISTENING 2704
TCP 0.0.0.0:55672 0.0.0.0:0 LISTENING 2704
TCP 127.0.0.1:5672 127.0.0.1:61775 ESTABLISHED 2704
TCP 127.0.0.1:15672 127.0.0.1:57671 ESTABLISHED 2704
TCP 127.0.0.1:57671 127.0.0.1:15672 ESTABLISHED 8408
TCP 127.0.0.1:61775 127.0.0.1:5672 ESTABLISHED 10312
TCP [::]:5672 [::]:0 LISTENING 2704
I keep getting following error regarding consumer. I am able to push things into RabbitMQ but not able to consume because of this error.
WARN : org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer -
Consumer raised exception, processing can restart if the connection factory supports it.
Exception summary: org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: 127.0.0.1
INFO : org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer -
Restarting Consumer: tag=[null], channel=null, acknowledgeMode=AUTO
local queue size=0
Below is my mq-Config.properties file:
server.host=127.0.0.1
server.port=5672
search.service.vmhost=/
search.service.username=guest
search.service.password=guest
search.service.indexwriter.queue.name=search.service.indexwriter.queue.test
search.service.indexwriter.exchange.name=search.service.indexwriter.exchange.test
search.service.indexwriter.routing.key=search.service.indexwriter.routing.test
numberof.concurrentconsumer=10
max.failure.retry.attempts=3
Below is my mq-Config-consumer.properties file:
#######Consumer Properties######
retailer.syncservice.consumer.server.host=127.0.0.1
retailer.syncservice.consumer.server.port=5672
retailer.syncservice.consumer.service.vmhost=/
retailer.syncservice.consumer.service.username=guest
retailer.syncservice.consumer.service.password=guest
retailer.syncservice.consumer.queue.name=retailer.syncservice.queue.fanoutqueue.test
retailer.syncservice.consumer.exchange.name=retailer.consumer.direct.exchange.test
retailer.syncservice.consumer.routing.key=retailer.consumer.routingkey.test
numberof.concurrentconsumer=10
Can anybody suggest what is wrong with the consumer setup? I tried googling it but did not find satisfactory answer which solves my issue. So asking it here.
I solved it with the help of my colleague. It was really a silly mistake.
Tab Character after value in properties file
There was a after 127.0.0.1 in mq-Config.properties file:
server.host = 127.0.0.1#tab character was here
Because of that it was not able to connect. I guess rabbitMQ is not trimming things from properties file. So even if there is a space after your value it will behave unexpectedly.
I removed tab character.
server.host = 127.0.0.1
After that it worked.
I am having problems running an app I have developed in an EC2 instance. When I execute the .jar (java -jar app.jar), the SpringBoot app starts but it fails when trying to connect to my MySQL RDS database. The thing is when I run the app locally on my machine, It has no issues with the DB connection.
I have opened the port where the app is running (8090) and MySql port as well (3306) for inbound and outbound traffic:
This is the error I get:
2016-09-23 17:46:38.132 INFO 10161 --- [main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8090
2016-09-23 17:46:38.604 INFO 10161 --- [main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-23 17:46:38.605 INFO 10161 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.54
2016-09-23 17:46:38.724 INFO 10161 --- [ost startStop 1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-09-23 17:46:38.725 INFO 10161 --- [ost startStop 1] o.s.web.context.ContextLoader: Root WebApplicationContext: initialization completed in 5028 ms
2016-09-23 17:48:48.476 ERROR 10161 --- [ost startStop 1] o.a.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Any ideas how can i solve this problem?
Thank you very much for your help
Regards
Andres
From your description and log file, it's likely that network configuration is the cause here.
You might want to draw the network topology of your instances (region/availability zone, VPC, subnet, network acl, security group). This will be very helpful when you do more complex development work.
There are good references: VPC Introduction and Security in your VPC and Scenarios for Accessing a DB Instance in a VPC
I suggest the following actions for your troubleshooting:
Check security group (SG) configuration of your EC2 instance and RDS instance.
You can check this by going to EC2 Dashboard/RDS Dashboard -> Click on an instance and look at "Security Group" description, or you can click on the Setting icon (Show/Hide columns) and tick "Security Groups".
In RDS's SG configuration: make sure you have enable access from EC2 instance's SG to port 3306. You can do this by putting EC2 instance's SG ID into Source field of the config, as a "Custom IP" value. See the 1st scenario in the above reference for more detail.
Use mysql command line to test the connection between EC2 instance and RDS.
Hope it helps.
You need to perform following steps :
1) Go to EC2 instance and find security group you want access in RDS
2) Now go to your RDS security group and select inbound rules
Select ALL TCP and add your sg-xxx(security group)
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html
I am trying to get tweets via hbc-twitter4j-v3 . Example code is : https://github.com/twitter/hbc/blob/master/hbc-example/src/main/java/com/twitter/hbc/example/Twitter4jSampleStreamExample.java
For enabling authentication on proxy, I have also set system properties for host,port and authentication. But it is showing following error-
[main] INFO com.twitter.hbc.httpclient.BasicClient - New connection executed: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Establishing a connection
[main] INFO com.twitter.hbc.httpclient.BasicClient - Stopping the client: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true
[main] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 exit event - Stopped by user: waiting for 5000 ms
[main] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Client thread failed to finish in 5000 millis
[main] INFO com.twitter.hbc.httpclient.BasicClient - Successfully stopped the client: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Unknown host - stream.twitter.com
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 failed to establish connection properly
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Done processing, preparing to close connection
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Shutting down httpclient connection manager
Any help??
Thanks in advance
Hopefully I haven't overlooked something but this is how it appears to me...
If by setting properties you mean the http.proxy* ones, I don't think it will work as hosebird-client uses Apache's HTTP client under the hood which doesn't seem to use them.
From a cursory glance at the code, specifically around the ClientBuilder, it doesn't look like hbc supports proxy configuration - perhaps they have a good reason not to or just don't need the feature themselves, maybe try requesting it?
It looks like one of the ways you can get HttpClient to use a proxy is by adding it to the HttpParams object, e.g.:
HttpParams params = ...
HttpHost proxy = new HttpHost(hostname, port);
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
Whilst the HttpParams object isn't exposed anywhere you could potentially extend the ClientBuilder in order to supply your proxy configuration. If you look at the ClientBuilder#build() method, you can see where the HttpParams object is being set up. Good luck!
EDIT: Additionally, this issue indicates there are no plans to add proxy support directly in hbc.