2017-08-11 4 views
0

Azure Service Busにはスケジュールされたメッセージを送信する機能があります。 AMQPプロトコルと 送信予定のmessagesesは、ここで説明:https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response#message-operationsJMSを使用してAzureサービスバスにスケジュールメッセージを送信する方法

スケジュールメッセージを。 リクエスト

要求メッセージは、次のアプリケーションのプロパティを含める必要があります。

|キー|値|タイプ|必須|値の内容

|操作|文字列|はいcom.microsoft:schedule - メッセージ

| com.microsoft:server-timeout | uint |いいえ|操作サーバーのタイムアウト(ミリ秒単位)。

私はSpring Frameworkのjava JmsTemplateを使用してAzure Service Busで動作します。 スケジュールされたメッセージを送信するメッセージメッセージヘッダーはどのようにマップされますか?

序メッセージ-produce
@Test 
public void sendMessageWithHeaders() { 


    jmsTemplate.send("test-topic-2", new MessageCreator() { 
     @Override 
     public Message createMessage(Session session) throws JMSException { 
      TextMessage textMessage = session.createTextMessage("test-123"); 
      ((JmsTextMessage) textMessage).setValidatePropertyNames(false); 
      textMessage.setStringProperty("operation", "com.microsoft:schedule-message"); 

      textMessage.setIntProperty("com.microsoft:server-timeout", 100000); 
      return textMessage; 
     } 
    }); 
} 

答えて

1

このコード作業:

アズールSB x-opt-scheduled-enqueue-time

static final long ONE_MINUTE_IN_MILLIS=60000;//millisecs 

@Test 
public void sendMessageWithHeaders() { 


    jmsTemplate.send(queueName, new MessageCreator() { 
     @Override 
     public Message createMessage(Session session) throws JMSException { 
      TextMessage textMessage = session.createTextMessage("test-123"); 
      ((JmsTextMessage) textMessage).setValidatePropertyNames(false); 

      org.apache.qpid.proton.message.Message amqpMessage = ((AmqpJmsTextMessageFacade)((JmsTextMessage)textMessage).getFacade()).getAmqpMessage(); 
      HashMap applicationPropertiesMap = new HashMap(); 
      applicationPropertiesMap.put("operation", "com.microsoft:schedule-message"); 
      applicationPropertiesMap.put("com.microsoft:server-timeout", 100000000); 
      amqpMessage.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap)); 

      Calendar date = Calendar.getInstance(); 
      long t= date.getTimeInMillis(); 
      Date afterAddingTenMins=new Date(t + (10 * ONE_MINUTE_IN_MILLIS)); 

      amqpMessage.getMessageAnnotations().getValue().put(Symbol.valueOf("x-opt-scheduled-enqueue-time"), afterAddingTenMins); 

      return textMessage; 
     } 
    }); 
} 
文書化されていないメッセージ注釈ヘッダーを使用
関連する問題