2017-11-05 21 views
0

Wildfly 10에서는 MDB의 주석 일부를 관련 리소스 어댑터로 옮기고 싶습니다.Wildfly 10에서 MDB 조회 속성을 Java 소스 코드의 컴파일 타임에 바인딩하지 않고 독립 실행 형 -full.xml에 지정할 수 있습니까?

(참조 페이지에서 여기에 복사) 다음과 같이 MDB에 주석을 달 수 Connect a pooled-connection-factory to a Remote Artemis Server 하나에 따르면 : 시간을 호출하는 컴파일 타임에서 조회 결정을 연기 할 수있는 방법이

@ResourceAdapter("remote-artemis") 
@MessageDriven(name = "MyMDB", activationConfig = { 
    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"), 
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"), 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") 
}) 
public class MyMDB implements MessageListener { 
//  
} 

있습니까? "

@ResourceAdapter("my-remote") 
@MessageDriven(name = "MyMDB", activationConfig = { 
    //try specifying the next 2 properties in the configuration file 
    //@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"), 
    //@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"), 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") 
}) 
public class MyMDB implements MessageListener { 
//  
} 

을 그리고 구성 내 - : 내 독립-full.xml

나는 다음과 같이 MDB에 주석을 시도의 속성"useJNDI "와"대상 "의 값을 지정하고 싶습니다 독립-full.xml에서 "원격 다음과 같이

<pooled-connection-factory name="my-remote" entries="jms/RemoteCF" 
    connectors="batch-connector" consumer-window-size="0" 
    useJNDI="false" destination="myQueue" 
    user="user" password="password" /> 

그러나 다음과 같은 오류 메시지가 점점 :

Message: WFLYCTL0376: Unexpected attribute 'useJNDI' encountered. Valid attributes are: 'entries, discovery-group, connectors, ha, client-failure-check-period, connection-ttl, call-timeout, call-failover-timeout, consumer-window-size, consumer-max-rate, confirmation-window-size, producer-window-size, producer-max-rate, protocol-manager-factory, compress-large-messages, cache-large-message-client, min-large-message-size, client-id, dups-ok-batch-size, transaction-batch-size, block-on-acknowledge, block-on-non-durable-send, block-on-durable-send, auto-group, pre-acknowledge, retry-interval, retry-interval-multiplier, max-retry-interval, reconnect-attempts, failover-on-initial-connection, connection-load-balancing-policy-class-name, use-global-pools, scheduled-thread-pool-max-size, thread-pool-max-size, group-id, transaction, user, password, min-pool-size, use-auto-recovery, max-pool-size, managed-connection-pool, enlistment-trace, initial-message-packet-size, initial-connect-attempts' 

컴파일 타임에 조회 속성을 지정해야합니까?
하나의 Wildfly 인스턴스가 jndi를 사용하여 조회해야하고 non-JNDI 이름을 사용하여 다른 조회를해야하는 경우, 실제로는 약간 다르게 주석 처리 된 두 개의 MDB를 작성해야합니까?

+0

리조트 어댑터가 xml에 구성되어 있으면 @ResourceAdapter를 제외하고 mdb 주석이 필요하지 않습니다. – Nicholas

답변

2

pooled-connection-factory>는 실제로 구성을 용이하게하기 위해 HornetQ JCA 리소스 어댑터의 맨 위에있는 외관입니다. < inbound-config> 요소 (자세한 내용은 스키마 참조)에 나와있는 제한된 구성 등록 정보 세트 외에도 모든 구성 등록 정보는 아웃 바운드 어댑터에만 적용됩니다 (즉, 인바운드 어댑터를 사용하는 MDB에는 적용되지 않습니다). MDB에서 사용되는 인바운드 어댑터는 실제로 주석 또는 배포 설명자 (예 : ejb-jar.xml)로 구성됩니다.

원하는 것을 얻으려면 배치 디스크립터에 구성을 외부화하거나 주석에서 시스템 특성 대체를 사용할 수 있습니다. 후자를 구현하려면 다음이 필요합니다에 : 서버 설정에서 true로

  1. 설정 < 주석 재산권-교체>
  2. 설정 < JBoss에 설명 재산권-교체> true로 서버에 설정
  3. 를 사용하여 $ {} 주석의 구문 예 :

    @ActivationConfigProperty(propertyName = "destination", propertyValue = "${myDestinationProperty}") 
    
  4. , 당신의 서버 설정에서 예를 시스템 등록 정보를 해당 정의 :

    <system-properties> 
        <property name="myDestinationProperty" value="myQueue"/> 
    </system-properties> 
    

분명히하기 위해, 아무것도 컴파일시에 주석으로 수행되지 않습니다. MDB가 활성화 될 때 배포시에 모두 읽습니다.

+0

감사합니다 저스틴. Btw, 나는 또한 서버 설정에서 jboss-descriptor-property-replacement를 true로 설정해야했습니다. 아마도 당신은 당신의 대답에 그것을 추가 할 수 있습니다.$ {}는 속성의 값을 얻기 위해서만 사용할 수 있습니까? 아니면 조건식을 지정할 수도 있습니까? – inor

+1

콜론 (예 : $ {propertyName : defaultValue})을 사용하여 속성의 기본값을 지정할 수 있지만 $ {} 구문은 다른 종류의 표현식을 지원하지 않습니다. –