0

I am new to rabbitmq and I am trying to send a .sh file in rabbitmq. I have setup my queue and exchanges. I am using spring-amqp and I can send json messages with my listerner container

public SimpleMessageListenerContainer messageListenerContainer() {
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
        container.setQueues(topicQueue());
        container.setAcknowledgeMode(AcknowledgeMode.AUTO);
        container.setMessageListener(new MessageListenerAdapter(pageListener(), jsonMessageConverter()));  
        return container;
}

but I am not sure how to send a sh file and write it in my pagelistener. Any idea how to do it?

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
user3915942
  • 27
  • 1
  • 5

1 Answers1

1

You need to read the file and send the content.

You can use a SimpleMessageConverter (the default) and if the content_type property is text/plain, you'll get a String; otherwise you'll get a byte[].

On the receiving side (presumably) you'd have to write it to a file and set the permissions.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thanks for your reply. I was able to write my sh file. But my problem is I need to send both my json and sh file and I need to write them to different files. So I tried setting up 2 queues and a Exchange but I am not sure how to bind them. I was thinking if I set up 2 queues and a Single exchange then I could sent two page queue listener and write them to different files. But I am not sure how to set it up. Can you provide me any suggestions on it – user3915942 Apr 17 '15 at 14:09
  • You simply bind each queue with a different routing key. You can either create two different listener containers, one for each queue, or a single container with a `ContentTypeDelegatingMessageConverter` and have your listener receive an `Object`. – Gary Russell Apr 17 '15 at 14:15
  • Got it.. Thanks! I have setup two different listener container for each queue and It works. – user3915942 Apr 17 '15 at 17:13