Moving a doc from client queue

Hello,

We use wME 4.11 SP14 in production environment and we face some problems with corrupted queues. The problem concern the Logger Adapter, which will not able to manage the ‘Logger-Queue’ client.

To resolve this problem, I am obliged to clean the queue of this client. But this solution is not pertinent. It is better to use another solution, which imply the destruction of the first document, arguing that it would be the only corrupted.

I do not find in the webMethods tools this kind of program. So I try to develop it. This is the program :

public static void main (String args)
{
String HostName="";
String brokerName="";
String idclient=""; // Input
BrokerConnectionDescriptor BcDesc = null;
HostName = args[0];
idclient = args[1];
int iIndex;

try
{

// Create a broker client
BrokerClient bac = BrokerClient.reconnect(HostName, brokerName, idclient, BcDesc);
System.out.println("Connexion OK to the client " + bac.getClientId());

System.out.println("Queue length = " + bac.getQueueLength());
System.out.println("We try to move the first document in the queue " + idclient);
BrokerEvent e;
String transId;
int transtag;
try {

// e = bac.getEvent(-1);
bac.acknowledge(1);
System.out.println("The document concerned is : ", e[0].toString());

} catch (BrokerException ex) { System.out.println(“sage is : PurgeHeaderDoc broker hostname:port clientName”);

System.out.println("Error on getting event\n"+ex); 

}
System.out.println("Queue length = " + bac.getQueueLength());

bac.disconnect();
}
catch(BrokerNullParameterException ne)
{
System.out.println("Error: " + ne);
}
catch (BrokerException ex)
{
System.err.println(ex.toString());
System.exit(1);
}
System.exit(0);
}

By executing this program, it success to display data of the first document in the queue, but it fail to move the first document !!

Thanks for any comments in advance.

Regards

For this code fragment:

// e = bac.getEvent(-1);
bac.acknowledge(1);

I assume that e = bac.getEvent(-1); is actually enabled in your code.

bac.acknowledge(1); is incorrect. You’re probably encountering BrokerInvalidAcknowledgementException with this. The parameter of this method is the event sequence number of the event you wish to acknowledge. Try this:

bac.acknowledge(e.getReceiptSequenceNumber());

This will remove the event from your queue.