I need to configure my app in order to send and consumes messages from/to a queue sitting on on anoter server. I have the following configuration in my application.properties:
spring.rabbitmq.host=amqp://cloudamqp.com/...
spring.rabbitmq.port=5672
spring.rabbitmq.username=jpkszgmu
spring.rabbitmq.password=***********************
And in my controller:
@Autowired
private RabbitTemplate rabbitTemplate;
@RequestMapping
public void send(@RequestParam String expediteur, @RequestParam String destinateur, @RequestParam String contenu){
int i = 1;
SMS s = new SMS("SMS00"+i, expediteur, destinateur, contenu);
this.rabbitTemplate.convertAndSend(MeService.queueName, s);
}
And the listener:
@RabbitListener(queues = queueName)
public void process(@Payload SMS s){
System.out.println("SMS Recus: "+s.toString());
r.send(s);
}
However I am getting errors saying the Unsatisfied dependency expressed through field 'rabbitTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException..
any help?
Full Trace of the error
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meController': Unsatisfied dependency expressed through field 'rabbitTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.NumberFormatException: For input string: "//jpkszgmu:[email protected]/jpkszgmu:5672"
UPDATE 3
ERROR 8392 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).
org.springframework.amqp.AmqpIOException: java.io.IOException at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:367) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:565) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1387) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:336) ~[spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:1135) [spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1200(SimpleMessageListenerContainer.java:96) [spring-rabbit-1.7.1.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1380) [spring-rabbit-1.7.1.RELEASE.jar:na] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] Caused by: java.io.IOException: null at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:381) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:909) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:799) ~[amqp-client-4.0.2.jar:4.0.2] at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:351) ~[spring-rabbit-1.7.1.RELEASE.jar:na] ... 9 common frames omitted Caused by: com.rabbitmq.client.ShutdownSignalException: connection error at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:366) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117) ~[amqp-client-4.0.2.jar:4.0.2] ... 14 common frames omitted Caused by: java.io.EOFException: null at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290) ~[na:1.8.0_111] at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-4.0.2.jar:4.0.2] at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:571) ~[amqp-client-4.0.2.jar:4.0.2] ... 1 common frames omitted