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

Windchill PDMlink Queue Customization.

SOLVED
Regular Member

Windchill PDMlink Queue Customization.

Can sommebody please help me with, how to create a SCHEDULE QUEUE Programmatically and add a schedule object to it!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Windchill PDMlink Queue Customization.

To create a queue you can use the following java code.

public static ScheduleQueue createScheduleQueueIfNecessary(String queueName) throws WTException {

ScheduleQueue sq = (ScheduleQueue) QueueHelper.manager.getQueue(queueName, ScheduleQueue.class);

logger.debug("ScheduledQueue '" + queueName + "' exists? sq=" + sq);

//create queue itself if necessary

if (sq == null) {

sq = QueueHelper.manager.createScheduleQueue(queueName);

logger.debug("created ScheduledQueue '" + queueName + "': sq=" + sq);

}

return sq;

}

And to create an entry in this queue the following method can be used

public static void addNewScheduleQueueEntry(ScheduleQueue sq, String className, String methodName, Timestamp nextTime, String message) throws WTException {

//Adding an entry

Class[] argTypes = {String.class};

Object[] args = {message};

WTPrincipal administrator = SessionHelper.manager.getAdministrator();

WTPrincipal previous = SessionContext.setEffectivePrincipal(administrator);

try {

sq.addEntry(administrator, methodName, className, argTypes, args, nextTime);

logger.debug("added new queueEntry to call '" + className + "." + methodName + "' nextScheduledTime=" + nextTime);

} finally {

SessionContext.setEffectivePrincipal(previous);

}

}

4 REPLIES 4

Re: Windchill PDMlink Queue Customization.

To create a queue you can use the following java code.

public static ScheduleQueue createScheduleQueueIfNecessary(String queueName) throws WTException {

ScheduleQueue sq = (ScheduleQueue) QueueHelper.manager.getQueue(queueName, ScheduleQueue.class);

logger.debug("ScheduledQueue '" + queueName + "' exists? sq=" + sq);

//create queue itself if necessary

if (sq == null) {

sq = QueueHelper.manager.createScheduleQueue(queueName);

logger.debug("created ScheduledQueue '" + queueName + "': sq=" + sq);

}

return sq;

}

And to create an entry in this queue the following method can be used

public static void addNewScheduleQueueEntry(ScheduleQueue sq, String className, String methodName, Timestamp nextTime, String message) throws WTException {

//Adding an entry

Class[] argTypes = {String.class};

Object[] args = {message};

WTPrincipal administrator = SessionHelper.manager.getAdministrator();

WTPrincipal previous = SessionContext.setEffectivePrincipal(administrator);

try {

sq.addEntry(administrator, methodName, className, argTypes, args, nextTime);

logger.debug("added new queueEntry to call '" + className + "." + methodName + "' nextScheduledTime=" + nextTime);

} finally {

SessionContext.setEffectivePrincipal(previous);

}

}

Re: Windchill PDMlink Queue Customization.

Hey Kumarappan, thaku very much for your time! But now when i am trying to add a schedule entry in to the queue, it's giving me null pointer exception.

Highlighted

Re: Windchill PDMlink Queue Customization.

Hi,

this is working code. Try check the name of the queue.

Kumarappan.S

Re: Windchill PDMlink Queue Customization.

Hi,

Thanx....It's working now....error was due to method context...Smiley Happy

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group