Hi Geoffrey, It's at least not intuitive to set a header to a message to get it published to a subtopic. This is probably true for selectors as well although I haven't checked it. I would have expected a setSubtopic method on message class or something like that.
Could you open an enhancement request for this? http://bugs.adobe.com/blazeds In the worst case, this should at least be documented. Thanks! Mete --- In [email protected], "Geoffrey" <[EMAIL PROTECTED]> wrote: > > Trial and error solved this since I couldn't find any examples or > documentation. > > The AsyncMessage object in the Java class needs to be set up like > this: > ... > msg.setDestination("siteMessages"); > msg.setHeader("DSSubtopic", "siteData.userSummary"); > ... > > "siteMessages" is the name of the destination set up in messaging- > config.xml. You also need to specify a DSSubtopic in the > AsyncMessage header. > > The Consumer(from AS or MXML) needs to have: > siteMessagesConsumer.subtopic = "siteData.*"; > > I found out that you can't just specify "userSummary" in the > DSSubtopic and set "siteMessagesConsumer.subtopic = '*'". This > resulted in an error when trying to actually publish a message. The > subtopic must be nested, "siteData.*". > > Hope this helps someone else. > Geoff > > --- In [email protected], "Geoffrey" <gtb104@> wrote: > > > > 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. > > >

