Results 1 to 3 of 3

Thread: RabbitTemplate/RabbitGatewaySupport incompatible with JDK proxy

  1. #1
    Join Date
    Jun 2006
    Posts
    12

    Default RabbitTemplate/RabbitGatewaySupport incompatible with JDK proxy

    We want to advise RabbitTemplate methods (such as send) as part of tracing support in our application. We are declaring a RabbitTemplate bean in our XML schema with a custom message converter and then injecting it into a bean of a class which extends RabbitGatewaySupport.

    Spring AOP autoproxy will generate a JDK proxy by default for our advice since RabbitTemplate implements the RabbitOperations interface. However, RabbitGatewaySupport expects a RabbitTemplate and thus the injection of the proxy fails. We can work around this by forcing the use of CGLIB proxies, but this changes all the proxies in our application, including transactional proxies introduced by tx:annotation-driven, and is clearly undesirable. Since RabbitGatewaySupport is relatively small we will probably either use a modified local version or just skip using it entirely.

    If RabbitGatewaySupport took an instance of RabbitOperations then I think a JDK proxy could be used. I think getConnectionFactory() would need to be added to the RabbitOperations interface and don't know if there are other places in Spring AMQP where RabbitTemplate can be injected that would be affected.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    I agree that is pretty bad. RabbitGatewaySupport is pretty thin though, so I expect the best workaround is to simply copy that and modify it. If you raise a ticket in JIRA we can look at fixing it properly.

  3. #3
    Join Date
    Jun 2006
    Posts
    12

    Default

    Thanks, I'll open a ticket. We are good with the work-around of copy/modifying or simply not using. Would be nice to have it fixed though in case features are added to RabbitGatewaySupport in the future that make the workaround less palatable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •