07-21-2012 05:00 PM
I am trying to send huge number of PIN messages using BB Java API.
Program makes delay of five seconds between two consecutive sending events in order to prevent overloading of server and avoid prblems with throttling threasure.
My program could send only 140 messages and exits. Is this possible that can be limit on operator side on number of messages per conection (or per day)?
07-21-2012 05:48 PM - edited 07-21-2012 05:49 PM
Your subject says PIM, but the Post says PIN. I assume you are talking about PIN messages.
I am not ware of a limit like that for PIN messages, and I am aware of processing that sends more than 140 PIN messages (though this is not done in a matter of minutes as yours would be), So my initial reaction is that if your program sends that number and exits, I would look at the processing and any error messages that this processing detects or reacts you. I think you might find the device log a useful tool for this, or log the processing yourself.
Do you know what causes the program to exit?
I presume the PIN message sending is not done on the Event Thread.
Edit:
Welcome to the forums!
07-22-2012 01:18 PM
Thanks for the ansver, peter_strange
You are right, I am about PIN messages. The subject is wrong.
Where I can find device log? Maybe the question is stupid, but I am newbie in BlackBerry development.
Yes, message sending is accomplished in separate thread.
Here is a code responcible for messages sending.
try
{
BlackBerryContactList contactList = (BlackBerryContactList)BlackBerryPIM.getInstance() .openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
Enumeration groupList = contactList.itemsByName(groupName, BlackBerryContactList.SEARCH_GROUPS);
// Take only first element. We are not expecting two groups with the same name
BlackBerryContactGroup group = (BlackBerryContactGroup) groupList.nextElement();
// Now iterate
int numberOfContacts = group.numContacts();
for(int i = 0; i < numberOfContacts; i++)
{
Contact contact = group.getContact(i);
String PIN = contact.getString(BlackBerryContact.PIN, 0);
if(PIN.length() != 0)
{
try
{
sleep(delay*1000);
sendMessage(PIN);
}
catch (InterruptedException e)
{
e.printStackTrace();
} // Wait before sending next message
}
}
}
catch (PIMException e)
{
e.printStackTrace();
}And sendMessage(PIN) is:
private boolean sendMessage(String PIN)
{
Store store = Session.getDefaultInstance().getStore();
//retrieve the sent folder
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
//create a new message and store it in the sent folder
Message msg = new Message(sentfolder);
PINAddress recipients[] = new PINAddress[1];
try
{
//create a pin address with destination address of PIN
recipients[0]= new PINAddress(PIN, " ");
}
catch (AddressException ae)
{
ae.printStackTrace();
}
try{
//add the recipient list to the message
msg.addRecipients(Message.RecipientType.TO, recipients);
//set a subject for the message
msg.setSubject(messageSubject);
msg.setContent(messageText);
//send the message
Transport.send(msg);
}
catch (MessagingException me)
{
System.err.println(me);
}
return true;
}