header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Akhil
Points:0
Posts:0

6/3/2011 6:05:44 AM

Title: problem with BlazeDs messaging using subtopics


hi,

I tried to send messages to Flex UI using subtopic, message are getting publish on server but are not recieved on UI.


flex-servlet.xml
---------------

<flex:message-destination id="RealTimeDataPush" allow-subtopics="true" subtopic-separator="."/>

<bean id="defaultMessageTemplate" class="org.springframework.flex.messaging.MessageTemplate" />
<bean id="abc" class="my.test.flex.services.MessagingService">
<constructor-arg ref="defaultMessageTemplate" />
</bean>


JAVA Code (my.test.flex.services.MessagingService.java)
---------
public class MessagingService {
private MessageTemplate template ;
public MessagingService(MessageTemplate template ){
this.template = template;
this.template.setDefaultDestination("RealTimeDataPush");
Thread t = new Thread("TEST_THREAD"){
public void run(){
int i=0;
while(true){
System.out.println("Publishing ::"+ i++);
int randNo= new Random().nextInt(10);

try {
Thread.sleep(1000*randNo);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

AsyncMessage msg = template.createMessageForDestination("RealTimeDataPush");
msg.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, "john");
msg.setBody("John"+randNo);
template.send(msg);

msg = template.createMessageForDestination("RealTimeDataPush");
msg.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, "abc");
msg.setBody("Abc"+randNo);
template.send(msg);
}
}
};
t.start();
}

}



Server Log
--------------
[BlazeDS]Sending message: Flex Message (flex.messaging.messages.AsyncMessage)
clientId = BEAD37D1-0B15-2B3D-61BB-A80CB5E60FF0
correlationId = null
destination = RealTimeDataPush
messageId = C023B013-7C0A-898E-49E6-4A76FF2C9735
timestamp = 1307104580803
timeToLive = 0
body = Flex Message (flex.messaging.messages.AsyncMessage)
clientId = BEAD37D1-0B15-2B3D-61BB-A80CB5E60FF0
correlationId = null
destination = RealTimeDataPush
messageId = C023B013-6F97-D608-88DF-4EDD3FF370A8
timestamp = 1307104580803
timeToLive = 0
body = John8:0
hdr(DSSubtopic) = john
to subscribed clientIds: []
[BlazeDS]After invoke service: message-service; execution time = 0ms
[BlazeDS]After invoke service: message-service
reply: null


Flex UI code
-----------------

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" initialize="connectToRtDataSource()" >
<fx:Script>
private function connectToRtDataSource():void{
rtDataConsumer.subtopic = "john";
rtDataConsumer.subscribe();
}
protected function rtDataConsumer_messageHandler(event:MessageEvent):void{

Alert.show(event.message.toString());
}
protected function rtDataConsumer_faultHandler(event:MessageFaultEvent):void
{
Alert.show(event.faultDetail);

}
]]>
</fx:Script>

<mx:ChannelSet id="cs">
<mx:StreamingAMFChannel url="http://localhost:8080/APP/messagebroker/streamingamf"/>
<mx:AMFChannel url="http://localhost:8080/APP/messagebroker/amflongpolling"/>
<mx:AMFChannel url="http://localhost:8080/APP/messagebroker/amfpolling"/>
</mx:ChannelSet>
<s:Consumer id="rtDataConsumer" message="rtDataConsumer_messageHandler(event)" destination="RealTimeDataPush" channelSet="{cs}" fault="rtDataConsumer_faultHandler(event)"/>

</s:Application>




1
Salvio
Points: 0
Posts:0
6/8/2011 10:43:00 PM



you can find a very good tutorial here to use Blazeds with flash builder

http://learn.adobe.com/wiki/display/Flex/Creating+a+BlazeDS+messaging+application+in+Flex+Builder

2
Connor
Points: 0
Posts:0
6/8/2011 11:05:20 PM



this topic should help you about using subtopics

http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WSc3ff6d0ea77859461172e0811f00f7045b-7f92Update.html


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+4 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions