I'm using BlazeDS to send messages in Flex. Inside the UI component, I defined a producer like the one below:
<mx:Producer id="producer"
destination="cha开发者_高级运维t"
fault="faultHandler(event);"/>
I was wondering inside faultHandler how I'm able to identify what message causes the error. As it seems there's no way to get the reference to the original message.
This is the code snippet how the message is constructed and sent.
private function sendMessage():void {
var message:AsyncMessage = new AsyncMessage();
message.body = userName.text + ": " + input.text;
producer.send(message);
}
Thanks!
Doesn't look like the producer object holds on to a reference of the message object. You can add this by just extending the producer class and overriding the fault function and dispatching a custom event that contains the message.
some sudo code:
public class MyProducer extends Producer
{
public function MyProducer(){
super()
}
override public function fault(errMsg:ErrorMessage, msg:IMessage):void
{
var evt:MyMessageEvent = new MyMessageEvent(msg)
dispatch(evt);
super(errMsg, msg);
}
}
Then all you need to do is listen for the MyMessageEvent event and get your message.
精彩评论