Send data using a FireAndForgetDestination object

  1. Import the required classes and interfaces.
  2. Create a URI object to pass to the DestinationFactory class.
    URI uri = new URI("");
  3. Create a FireAndForgetDestination object.
    FireAndForgetDestination ffd = null;
  4. Retrieve the FireAndForgetDestination object for your context, if one exists.
        ffd = (FireAndForgetDestination) DestinationFactory.getSenderDestination
                                              ("MyContext", uri);
  5. If no FireAndForgetDestination exists, create one.
        if(ffd == null)
            ffd = DestinationFactory.createFireAndForgetDestination
                              (new Context("MyContext"), uri);
  6. Create a ByteMessage object and populate it with information to send to a web service.
        ByteMessage myMsg = ffd.createByteMessage();
        myMsg.setStringPayload("I love my BlackBerry device!");
  7. Cast your message as an HTTPMessage to set the HTTP method that you want to use.
        ((HttpMessage) myMsg).setMethod(HttpMessage.POST);
  8. Send the message to the web service.
  9. Catch any errors that occur if the message could not be sent for some reason.
        catch (Exception e)
            // Process the error

Was this information helpful? Send us your comments.