이 콘텐츠는 선택한 언어로 제공되지 않습니다.

19.2. Using a Custom Destination Resolver


Overview

Destination resolvers are a part of the JMS technology Red Hat JBoss Fuse inherits from the Spring Framework. They convert string destination names into JMS Destination objects. For example, if you specify an endpoint's destination using the destinationName attribute, the endpoint will use a destination resolver to get the appropriate JMS Destination object. Destination resolvers are also used if a destination chooser returns a string and not a JMS Destination object.
Red Hat JBoss Fuse JMS endpoints default to using the DynamicDestinationResolver destination resolver provided by the Spring Framework. This destination resolver uses the standard JMS Session.createTopic() and Session.createQueue() methods to resolve destination names.
Red Hat JBoss Fuse JMS endpoints can also use the Spring Framework's JndiDestinationResolver destination resolver. This destination resolver uses the string destination name to perform a JNDI lookup for the JMS destination. If JMS destination is not returned from the JNDI lookup, the resolver resorts to dynamically resolving the destination name. For information on configuring and endpoint to use the JndiDestinationResolver destination resolver. See the section called “Configuring an endpoint to use a destination resolver”.

Implementing a destination resolver

Destination resolvers implement the org.springframework.jms.support.destination.DestinationResolver interface. The interface has a single method: resolveDestinationName().
The resolveDestinationName() method, whose signature shown in Example 19.5, “Destination Resolver Method”, takes three parameters: a JMS session, a destination name, and a boolean specifying if the destination is a JMS topic.[2] It returns a JMS destination that correlates to the provided destination name.

Example 19.5. Destination Resolver Method

Destination resolveDestinationName(Session session,
                                   String destinationName,
                                   boolean pubSubDomain)
    throws JMSException;
Example 19.6, “Simple Destination Resolver” shows a simple destination resolver implementation.

Example 19.6. Simple Destination Resolver

package com.widgetVendor.example;

import org.springframework.jms.support.destination.DestinationResolver;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session;

public class widgetDestinationResolver implements DestinationResolver
{
 
  public Destination resolveDestinationName(Session session,
                                            String destinationName,
                                            boolean pubSubDomain)
  throws JMSException
  {
    if (pubSubDomain)
    {
      return session.createTopic(destinationName);
    }
    else
    {
      return session.createQueue(destinationName);
    }
  }
}
Copy to Clipboard Toggle word wrap

Configuring an endpoint to use a destination resolver

You can configure an endpoint to use a custom destination resolver in one of two ways. The recommended way is to configure the destination resolver as a bean and have the endpoint reference the destination resolver's bean. The other way is to explicitly include the destination resolver's configuration as a child of the endpoint.
As shown in Example 19.7, “Configuring a Destination Resolver with a Bean Reference”, configuring an endpoint's destination resolver using a bean reference is a two step process:
  1. Configure a bean element for your destination resolver.
  2. Add a destinationResolver attribute that references the destination resolver's bean to your endpoint.

Example 19.7. Configuring a Destination Resolver with a Bean Reference

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       ... >
  ...
  <jms:consumer service="my:widgetService"
                endpoint="jbiWidget"
                destinationName="widgetQueue"
                connectionFactory="#connectionFactory"
                destinationResolver="#widgetDestinationResolver" />
  <bean id="widgetDestinationResolver"
        class="com.widgetVendor.example.widgetDestinationResolver" />
  ...
</beans>
Copy to Clipboard Toggle word wrap
Example 19.8, “Explicitly Configuring a Destination Resolver” shows an example configuration using the jms:destinationResolver element. This method is less flexible than the recommended method because other endpoints cannot reuse the destination resolver's configuration.

Example 19.8. Explicitly Configuring a Destination Resolver

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       ... >
  ...
  <jms:consumer service="my:widgetService"
                endpoint="jbiWidget"
                destinationName="widgetQueue"
                connectionFactory="#connectionFactory">
    <jms:destinationResolver>
      <bean id="widgetDestinationResolver"
            class="com.widgetVendor.example.widgetDestinationResolver" />
    </jms:destinationChooser>
  </jms:consumer>
  ...
</beans>
Copy to Clipboard Toggle word wrap


[2] If the value is false, a JMS queue will be returned.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat