Re: [rabbitmq-users] Spring AMPQ Configuration - 'connectionFactory' or 'rabbitTemplate' is required

685 views
Skip to first unread message
Message has been deleted

Michael Klishin

unread,
Feb 21, 2015, 5:56:12 PM2/21/15
to rabbitm...@googlegroups.com, appren...@googlemail.com
  On 22 February 2015 at 01:28:58, appren...@googlemail.com (appren...@googlemail.com) wrote:
> Trying to setup Spring AMPQ but I getting an exception. I have
> these beans defined in the @Configuration Class (see below).
>
> Exception
>
>
> 21:52:20.566 [localhost-startStop-1] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean
> - Closing JPA EntityManagerFactory for persistence unit 'default'
> 21:52:20.567 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader
> - Context initialization failed
> org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'messageQueueSender' defined
> in file [/Users/khaliluddin/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProjectA/WEB-INF/classes/com/queue/service/impl/MessageQueueSenderImpl.class]:
> Invocation of init method failed; nested exception is java.lang.IllegalArgumentException:
> 'connectionFactory' or 'rabbitTemplate' is required

Spring AMQP questions should be directed to Stack Overflow, tag spring-amqp. We do not maintain
that project.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Gary Russell

unread,
Feb 21, 2015, 6:28:42 PM2/21/15
to Michael Klishin, rabbitm...@googlegroups.com, appren...@googlemail.com
Yes; please use Stack Overflow for Spring AMQP.

That said...

Caused by: java.lang.IllegalArgumentException: 'connectionFactory' or 'rabbitTemplate' is required
at org.springframework.amqp.rabbit.core.support.RabbitGatewaySupport.afterPropertiesSet(RabbitGatewaySupport.java:99) ~[spring-rabbit-1.4.3.RELEASE.jar:na]

You don't show a RabbitGatewaySupport in your configuration (presumably messageQueueSender is a subclass) but the error is pretty clear - it needs one of the required dependencies.

But, please continue this discussion on Stack Overflow.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send an email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

appren...@googlemail.com

unread,
Feb 21, 2015, 6:46:54 PM2/21/15
to rabbitm...@googlegroups.com, mkli...@pivotal.io, appren...@googlemail.com
Will post to Stackoverflow in future.  

Here is the class that extends RabbitGatewaySupport.

@Service("messageQueueSender")

public class MessageQueueSenderImpl extends RabbitGatewaySupport implements MessageQueueSender {

    @Override

    public void sendMessage(final Message message) {

        getRabbitTemplate().convertAndSend(message);

Gary Russell

unread,
Feb 21, 2015, 6:58:27 PM2/21/15
to appren...@googlemail.com, rabbitm...@googlegroups.com, Michael Klishin
Right, but you are not showing a configuration for it; you need an @Bean definition for it and need to provide it with a reference to your rabbitTemplate bean in its @Bean definition...

messageQueueSender.setRabbitTemplate(rabbitTemplate());

You can't use autowiring/component scan for this component unless you @Autwire your own RabbitTemplate (to be honest, there is not much value in subclassing the gateway for your scenario, using java config).



To post to this group, send email to rabbitm...@googlegroups.com.
Message has been deleted

Gary Russell

unread,
Feb 22, 2015, 9:41:16 AM2/22/15
to appren...@googlemail.com, rabbitm...@googlegroups.com, Michael Klishin

@Service("messageQueueSender")

public class MessageQueueSenderImpl implements MessageQueueSender {

    @Autowired

    private RabbitTemplate;


    @Override

    public void sendMessage(final Message message) {

        thia.rabbitTemplate.convertAndSend(message);

    }

}

If you have more questions, please move it to Stack Overflow rather than polluting this group.

On Sun, Feb 22, 2015 at 2:51 AM, <appren...@googlemail.com> wrote:
Can I get an example on how you would do it?
Reply all
Reply to author
Forward
0 new messages