kavita
kavita

Reputation: 845

Chat history forwardedMessages is empty ArrayList

I am trying to implement a java smack client interacting with Openfire server. I have added the plugin for Monitoring service, also enabled archiving. Now I can see the chat history in the openFire Admin Console. I would like to do the same using Smack. This is the code I have written.

XMPPTCPConnection connection = connectToXMPP(Constants.XMPPADMINUSERNAME, Constants.XMPPADMINPWD ,Constants.XMPPDOMAIN);

MamManager mamManager = MamManager.getInstanceFor(connection);
try {
    DataForm form = new DataForm(DataForm.Type.submit);
    FormField field = new FormField(FormField.FORM_TYPE);
    field.setType(FormField.Type.hidden);
    field.addValue(MamElements.NAMESPACE);
    form.addField(field);

    FormField formField = new FormField("with");
    formField.addValue("[email protected]");
    form.addField(formField);
    boolean isSupported = mamManager.isSupported();
    // "" empty string for before
    RSMSet rsmSet = new RSMSet(maxResults, "", RSMSet.PageDirection.before);
    MamManager.MamQueryResult mamQueryResult = mamManager.page(form, rsmSet);
   // MamManager.MamQueryResult mamQueryResult1 = mamManager.queryArchive(JidCreate.from("[email protected]"));
    return mamQueryResult;

} catch (Exception e) {
    e.printStackTrace();
}
return null;

Now the problem is the forwardedMessages ArrayList is always null. What am I doing wrong?? isSupported is true and I can see the chathistory on admin console… Please guide…

Upvotes: 3

Views: 175

Answers (1)

Guus
Guus

Reputation: 3006

I notice that you're trying to get the last few archived messages, which makes sense. I'm not sure if your 'before' value should be empty though. For testing purposes, try reversing the page direction, and see if you can get the first/oldest few archived messages.

Upvotes: 1

Related Questions