cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Experience with Queues

Highlighted
Newbie

Experience with Queues

Hello,

does anyone have experience with (programming) Queues in Windchill? I want to add some entries to a queue and then process this entries. I am looking for an example e.g. in java, how to manage this. Any help is welcome, also additional documantions would be fine.

Best Regards

Stefan



5 REPLIES 5
Highlighted

RE: Experience with Queues

Hi Stefan,
Primarily there are two types of queues in Windchill, Processing Queue and Schedule Queue. Here is a snippet that will work with Processing Queue. Only requirement is that the method you are adding to queue should be public and static. Code for Schedule Queue also will be along the same lines.


ProcessingQueue processingQueue = (ProcessingQueue)QueueHelper.manager.getQueue("CustomQueue", wt.queue.ProcessingQueue.class);
Class aclass[] = {
wt.fc.ObjectIdentifier.class
};
Object aobj[] = {
objectIdentifier
};

wtprincipal = SessionHelper.manager.getAdministrator();

String CLASSNAME = (WorkflowUtilities.class).getName();
String methodName = "extractBOM";
processingQueue.addEntry(wtprincipal, , CLASSNAME,methodName, aclass, aobj);



Regards,


Prathap

In Reply to:

Hello,

does anyone have experience with (programming) Queues in Windchill? I want to add some entries to a queue and then process this entries. I am looking for an example e.g. in java, how to manage this. Any help is welcome, also additional documantions would be fine.

Best Regards

Stefan



Highlighted

RE: Experience with Queues

Hello,

thanks for the code example. My problem for the moment is, that I have to start with queues, so as I understood, the first step is to add some entries into a queue. I have tried to add a string as parameter, but got an error, here is my code:

ProcessingQueue testQueue = (ProcessingQueue)QueueHelper.manager.getQueue("testQueue", wt.queue.ProcessingQueue.class);



WTPrincipal wtprincipal = SessionHelper.manager.getAdministrator();



String CLASSNAME = (com.sg.QueueTest.class).getName();

String methodName = "doJob";



Class aclass[] = { String.class };

Object aobj[] = { "my test string" };



testQueue.addEntry(wtprincipal, methodName, CLASSNAME, aclass, aobj);

The class and the method are also availabe on server, the method, which should process the job looks like:



public void doJob( String str ) {

System.out.println( "doing a job: " + str );

return; }

My prolem for the moment is, that adding the job throws the following exception, any idea what the problem is?

Regards

Stefan

008-07-30 10:38:51,856 ERROR [main] root - * Couldn't add entry to queue 'testQueue'

2008-07-30 10:38:51,856 ERROR [main] root - * Entry: com.sg.QueueTest.doJob

2008-07-30 10:38:51,856 ERROR [main] root - * Args: [Ljava.lang.Object;@95cfbe

2008-07-30 10:38:51,856 ERROR [main] root - * Exception:

2008-07-30 10:38:51,871 ERROR [main] root - (wt.pom.pomResource/0) wt.pom.POMInitException: A persistence error occurred. System message follows:

Nested exception is: wt.method.MethodServerException: No active method context

Exception in thread "main" (wt.pom.pomResource/0) wt.pom.POMInitException: A persistence error occurred. System message follows:

Nested exception is: wt.method.MethodServerException: No active method context

at wt.method.MethodContext.getContext(MethodContext.java:1150)

at wt.pom.PersistentObjectManager.getPom(PersistentObjectManager.java:277)

at wt.pom.Transaction.start(Transaction.java:441)

at wt.queue.ProcessingQueue.addEntry(ProcessingQueue.java:469)

at com.sg.QueueTest.doIt(QueueTest.java:77)

at com.sg.QueueTest.main(QueueTest.java:37)

Highlighted

RE: Experience with Queues

Hi Stefan,

how are you running your code? from command line, from a JSP.... ?

Iker Mendiola

Prambanan IT Services
http://en.prambanan-it.com





Iker Mendiola
Prambanan IT Services
Highlighted

Experience with Queues

Hi Stephan,
Check the following conditions and see if any of them helps.
1. The method you are calling should be public and static.
2. Your 'testQueue' should already exist. It doesn't create one for you.
3. You need a method context to run this code. This code should be on the
server side(method server), typically run from Windchill Services.

Regards,
Prathap




Highlighted

RE: Experience with Queues

Hello,

the code was running from client, now I changed to the server and now it works.

Regards

Stefan



Announcements