Pubsub - hello world example

after submmited “a book” to node “testnode”, for subsequent time, cannot submit to the same node because of error 409? is this normal? in this case, how to submit multiple “books” to same node" so that user will receive update ?

I am not sure what that error is. Try running it with the debug console (VM arg -Dsmack.debugEnabled=true and include smackx-debug.jar) so you can see the full error message. It will have a more specific reason for failure.

You should be able to send multiple items to the node.

this is my debug log

admin@userx/Smack</i q>


0

Looks like you are trying to create a node “ghost” that already exists. Are you running the same sample code repeatedly, including creating the node? The error is not occuring in publishing.

correct. i run the publishing test application repeatly . if i change Node myNode = manager.createNode(“ghost”, form); to Node myNode =manager.getNode(“ghost”) ; for subsequent time, i get error 404 node not found instead

hello,folks

I have a packet ,(

send:

and receive:

)

I want to Publish-Subscribe this packet.If item is changed (e.g. new create ,update or delete),openfire server notified me that ! How can I use smack pubsub ?

Thanks in advance,

this is maybe a bit stupid question, but I have a problem with the line

Item item = new Item(itemId, payload);

Eclipse gives me this error: The type Item is not generic; it cannot be parameterized with arguments

My JRE is 1.16 and my SDK is 1.6, so my Java supports generics, but I don’t know what’s the problem here.

please help

thanks in advance

I’m using smack api for android - asmack, but when I use smackx-pubsub.0.6 I get no error.

solved it, hopefuly, sry for bothering

Change **Item **to PayloadItem

Item is not generic, but it’s subclass which supports payloads is.

I’m getting an error at this exact line:

for (PayloadItem item : e.getItems()) {

Error:


incompatible types
found : java.lang.Object
required: org.jivesoftware.smackx.pubsub.PayloadItem<org.jivesoftware.smackx.pubsub.Simpl ePayload>

Hi Guys

I am new to J2ME.I think it is stupid question where to use this pub sub hello world example code

please help me

if anybody have solution for Item(node) not found error, Please post the solution to resolvethat problem.

Hello,

I’m trying you example code but this doesn’t work. I get 2 errors.

The first error is with this line I get “type org.jivesoftware.smackx.pubsub.Item does not take parameterstype org.jivesoftware.smackx.pubsub.Item does not take parameters” :

Item<SimplePayload> item = new Item<SimplePayload>(itemId, payload);

The second problems is with this line :

myNode.addItemEventListener(myEventHandler);

Where do you create “myEventHandler” ? I don’t see it in your example.

Thanks for the help!

The first error is because the code has changed since the example was written. Try PayloadItem instead of Item.

The second is left as an exercise for the reader

Just look at the API and check the documentation, it’s a pretty interface.

Yes after re-reading all the messages again I finally found I should use PayloadItem.

Now I have a problem with :

myNode.publish(item);

The method publish doesn’t seem to exists (I get “cannot find symbol”). There is a new method to send the item to the pubsub service?

Thanks!

Any help?

Thanks.

You need to look at the documentation as this example is becoming rather dated. The Node is now a LeafNode.

Hii,

This page has been very helpful for me.

I am unable to extract the data from the item recieved.

Can u give me a link to a pubusb parser to extract the data from the item recieved.

Still not able to successfuly create an item to send.

Thanks in advance!

Can some one post an updated pubsub hello world example…

Thanks guyz and good wishes

This would be the default case if you have included a payload.

public void handlePublishedItems(ItemPublishEvent items)

{

PayloadItem item = items.getItems().get(0);

SimplePayload payload = item.getPayload();

String payloadData = payload.toXML();

}

When I send notification the receiver’s payload contains null for each tag. For example:

Lord of the Rings is received as nullnullLord of the Ringsnullnull

Any thoughts?