Announcement Announcement Module
Collapse
No announcement yet.
HelloWorld example setting queue parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HelloWorld example setting queue parameters

    I've been a .NET developer for several years with some Java experience coming from fixing bugs in a couple of servers written in Java over the years....

    I've been asked to evaluate Spring Source toolkit for Java as a possible new direction for the department...the management here is interested in Java and are willing to put up with the learning curve etc. that it would take since every other developer here has been working with .NET for years too.

    Now on to my first problem...it seems like it should be so simple..but maybe its the Spring framework or some templates getting in the way.

    In .NET I am doing this in my producer
    channel.QueueDeclare("events", True, False, False, Nothing)
    channel.QueueBind("events", "TestExchange", "Route1", Nothing)

    In the Spring consumer project I can't get it to work because it complains that the queue parameters are different. I googled the error and found that this is because the auto-delete and durable flags are not matching.
    That's fine, but in the HelloWorld example I never set those flags myself, so can't figure out how to set them so that they do match.

    The code in the Java example is
    template.setQueue("events");

    Anyone know how I'd go about getting access to the queue parameters here so that it would stop complaining and just work? the .NET example I wrote took me 5 minutes, and this Spring example is taking much longer than that.

    note: I actually had been signed up for the Spring.NET class in San Francisco last month but it got cancelled! So we're assuming there isn't much support for .NET using the Spring framework, hence the need to look at the Java version.
    Last edited by fremen93; Mar 21st, 2011, 12:27 PM.

  • #2
    I got a bit further along now.

    If I modify this
    @Bean
    public Queue helloWorlddQueue() {
    Queue x = new Queue("events");
    x.setDurable(true);
    x.setAutoDelete(false);
    return x;
    }

    It works fine...
    but if I delete that bean entirely it works fine too...
    so that seems to tell me that either the rabbittemplate or something else is using this Queue object if its there, otherwise it uses some default Queue object based on the string set earlier (template.setQueue("events")).
    But can't seem to find documentation telling me that.
    Its nice that the spring framework does so much for you, but it would be nice to know what its doing behind the scenes a bit more.

    Comment


    • #3
      Where did new Queue("events") come from? I'm looking at the hello world sample and it says

      Code:
      @Bean
      public Queue helloWorldQueue() {
      	return new Queue(this.helloWorldQueueName);
      }
      Have you got an old version of the sample (look on Github for the latest https://github.com/SpringSource/spring-amqp-samples)? What's the "Spring consumer project" that you are looking at?

      I don't really know what you were struggling with, but thanks for asking. It seems to me that maybe it wasn't Spring doing anything magic that got you started, just that eventually the queue was declared in the broker and wasn't deleted when either the broker or the client died because you changed the default settings of those flags. It shouldn't be any different in .NET, but then it looks like the code samples you give from .NET are not from Spring AMQP.NET.

      If you think it would be a easier API for beginners if RabbitTemplate accepted a Queue instead of a queue name (String) for receiving, I get that. Is that the problem?

      Comment

      Working...
      X