I see plenty of examples of how to do subtopics all from MXML/AS 
code, but how to you create a message in Java that has a subtopic?

Here are some code snippets:


:::messaging-config.xml:::
<destination id="siteMessages">
<properties>
<server>
<max-cache-size>1000</max-cache-size>
<allow-subtopics>true</allow-subtopics>
<subtopic-separator>.</subtopic-separator>
</server>
</properties>
<channels>
<channel ref="my-streaming-amf"/></channels>
</destination>


:::main.mxml:::
<mx:Script>
public function onCreationComplete():void {     
  siteMessagesConsumer.destination = "siteMessages";
  siteMessagesConsumer.subtopic = "*";
  siteMessagesConsumer.subscribe();
}

public function onSiteMessages( event:MessageEvent ):void {     
  trace("Got it!");
}
</mx:Script>

<mx:Consumer
  id="siteMessagesConsumer"
  message="onSiteMessages(event)"/>


:::MyDelegate.java:::
private void sendFlexMessage() throws MyException {
  MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
  String clientID = UUIDUtils.createUUID();

  // Generate a message
  AsyncMessage msg = new AsyncMessage();
  msg.setDestination("siteMessages.allUsers");
  msg.setClientId(clientID);
  msg.setMessageId(UUIDUtils.createUUID());
  msg.setTimestamp(System.currentTimeMillis());
  msg.setBody(getSomeObject());

  // Send a message
  msgBroker.routeMessageToService(msg, null);
}

The sendFlexMessage() method is called from somewhere else.  This 
worked when my destination was just "siteMessages".  But I want to 
send subtopics 
like "siteMessages.allUsers", "siteMessages.allTeams", etc.  I 
looked at the Java API for this stuff and saw nothing that jumped 
out like a setSubTopic() method, so I assumed that it was as simple 
as setting the destination to "something.something".  That seems to 
be the way they did it in the MXML/AS examples I saw, but when I try 
to send the message I get an error saying that there is 
no "siteMessages.allUsers" destination.

Any suggestions would be appreciated.

Reply via email to