How to Purge an MSMQ Outgoing Queue - msmq

Is there any way to purge an outgoing queue. It doesn't appear that I can do it with the MMC snap-in and when i try to purge it in code i get an error Format name is invalid the computer it's sending the messages to does not exist, so they will never be sent, however the queues filled up the max storage space for MSMQ so everytime my application tries to send another message i get the insufficient resources exception.
I've tried the following formats and they all fail with the exception format name is invalid
DIRECT=OS:COMPUTER\private$\queuename
OS:COMPUTER\private$\queuename
COMPUTER\private$\queuename

You should be able to purge it manually from the MMC snap-in. MSMQ gets very stingy when it reaches its storage limits, so a lot of operations will fail with "permission denied" and things like that.
The long-term solution obviously is to modify the configuration so there is enough storage space for your particular usage patterns.
Edit: You might be running into a limitation in the managed API related to admin capabilities and remote queues. Take a look at this article by Ingo Rammer. It even includes a p-invoke example.

it is possible use managed code to purge an outgoing queue:
using (var msgQueue = new MessageQueue(GetPrivateMqPath(queueName, remoteIP), QueueAccessMode.ReceiveAndAdmin))
{
msgQueue.Purge();
}
in which GetPrivateMqPath is:
if (!string.IsNullOrEmpty(remoteIP))
return String.Format("FORMATNAME:DIRECT=TCP:{0}\\private$\\{1}", remoteIP, queueName);
else
return #".\private$\" + queueName;
QueueAccessMode.ReceiveAndAdmin points to outgoing queue.

You could try FORMATNAME:DIRECT=OS:computer\PRIVATE$\queuename.

Related

How to fix the missing BLINDTRANSFER and ATTENDEDTRANSFER log entries in the queue_log file?

I write a wallboard for asterisk queue system. The document says that when a call is transferred away by an agent an ATTENDEDTRANSFER (or BLINDTRANSFER) event log should be added to the queue_log file automatically. Unfortunately there is no line for any transferred calls in the log file (queue_log in my case). Is there any setting to be changed to let the system to log them properly ?
When I check the CEL files, I see the transfer logs. So the system is logging correctly for CEL but not for queue_log.
I tried to transfer the call to another agent, to an IVR and to another user who is not an agent for any queue. The result is the same, no log for the transfer process.
Any suggestions ?
I use the following:
Asterisk Version: 13.22.0
Freepbx 14.0.5.25
All trunks and clients are connected via SIP
If your phone do transfer via internal features - no log entries.
You have parse AMI events for needed info.
Write your own queue wallboard is VERY hard task. Queue module have really alot of issues.
Can recommend read some already written modules like https://www.asternic.net or queuemetric

Gmail SMTP error - Temporary block?

I am using Gmail servers to send email from my system, with a program.
Recently I started getting errors like this:
Data command failed: 421 4.7.0 Temporary System Problem. Try again later (WS). 6sm3756432pab.11 - gsmtp
The reasons are given in the support.
Can anybody tell me what is the number of emails that can trigger this issue?
Or is it because of some other reasons?
If you are using your free Gmail account to send bulk emails your are likely to see this kind of responses early on as the service is not intended to send application transaction messages, newsletters etc., event to subscribers that has opted in.
The IMAP/SMTP service provided is for you to be able to use an email client like Microsoft Outlook with your Gmail account.
If you need to send transaction messages, I suggest you google "AWS SES" for starters.
I agree with Anubhav Shrimali that the error occurs if Gmail gets multiple requests simultaneously.
I had solved the problem using Nodemailer in Node.js by adding the 1 second delay between each successive email as follows:
array.foreach(function(data, index) {
setTimeout(() => {
sendmail();
}, 1000 * index);
function sendmail() {
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent' + info.response);
}
});
}
});
This error occurs if you are using scripts to send emails in quick successions.
An easy way out is to apply a sleep timer in between sending emails.
I applied a timer for 1 second between each successive email.
import time
time.sleep(1) // equivalent to 1 second sleep
I too had the same issue when I tried to send bulk emails using the multi threaded program in Java. Then I heard about Thread Pool Executor. I used it by setting Thread Pool size as 10. After that, this issue has been solved for me.
If this situation is encountered, it should be placed in the retry queue, and the monitoring will be notified if multiple retries fail.
Hope this link can help you:
https://support.google.com/a/answer/3726730
This is probably a result of bulk email sending from the same IP address. As mentioned, use the python sleep function so that there is a bit of a wait between sendings. I find that 1 second is not usually enough time for me, and I sometimes go with a random number of seconds between 1 and 5 for the most optimal results.
import random
import time
time.sleep(random.randint(1, 5))
Don't forget to import the correct modules.
have a rest for 20 minutes , and try again, the error gone

phpmailer error codes for outcome processing

I am building a mailout capability and it is working OK as far as it goes. However, I want to distinguish between various potential (high level) outcomes in order to determine what happens to each message after the current send attempt.
This must be a common requirement so I seem to be missing something pretty obvious, but I can't find anything that addresses it, either here or via Google or on PHPMailer site or .. . Possibly because there are so many questions about specific errors that I just can't find anything useful in all the other results.
At very high level:
Attempt send, and assess resulting error/result. Identify whether this message has been sent, must be retried later, or failed permanently.
- success -> update message status as 'SENT: OK'
- sent, but some issues (e.g. one recipient failed, others processed OK)-> 'SENT: some error'
- failed, due to temporary problem (e.g. connection problem, attachment open) -> 'TRY LATER'
- failed, due to message-specific problem that we should NOT try to resend-> 'FAILED: some error'
As I was unable to find an existing resource with e.g. a table of errors, I spent some time working through the phpmailerException code to try to build one myself, but it's not simple because a) they don't appear to have been designed in terms of this kind of grouping logic, b) it is not easy to uniquely identify a particular error: PHPMailer provides human-friendly messages, which are different in different languages, rather than an identifiable code - given that my solution will need to work across different language installations that's a problem!
Obviously SMTP itself provides a range of errorcodes which I could potentially use for this purpose, but how do I access these via PHPMailer? (This would work for me as I only use SMTP at this point - however, this would NOT work if other message transport like sendmail was used, so I would prefer a PHPMailer solution)
If you want individual result codes for individual address, you really need to send each message separately. If you do get errors on some recipients, they will be listed in the ErrorInfo property - look in the smtpSend function to see how the error string is assembled. I agree that it's not especially easy to parse that info out. The error messages in PHPMailer are generally more for the developer than the end user, so the translations are not that significant. You can get slightly more information about errors if you enable exceptions rather than relying only on return values.

hornetq message remain in queue after ack

We are using hornetq-core 2.2.21.Final stand-alone after reading a non-transnational message , the message still remains in queue although it acknowledge
session is created using
sessionFactory.createSession(true, true, 0)
locator setting:
val transConf = new TransportConfiguration(classOf[NettyConnectorFactory].getName,map)
val locator = HornetQClient.createServerLocatorWithoutHA(transConf)
locator.setBlockOnDurableSend(false)
locator.setBlockOnNonDurableSend(false)
locator.setAckBatchSize(0) // also tried without this setting
locator.setConsumerWindowSize(0)// also tried without this setting
Message is acknowledge using message.acknowledge ()
I think that the problem might be two queues on the same address
also tried to set the message expiration but it didn't help , messages are still piling up in the queue
please advise
It seems you are using the core api. Are you explicitly calling acknowledge on the messages?
If you have two queues on the same address ack will only ack the messages on the queue you are consuming. On that case the system is acting normally.

syslog-ng with unix-stream destination

I am trying to configure syslog-ng destination path to use unix-stream sockets for Inter process communication. I have gone throgh this documentation http://www.balabit.com/sites/default/files/documents/syslog-ng-ose-3.3-guides/en/syslog-ng-ose-v3.3-guide-admin-en/html/configuring_destinations_unixstream.html .
My syslog.conf(only part of it) for the same is as follows:
source s_dxtcp { tcp(ip(0.0.0.0) port(514)); };
filter f_request {program("dxall");};
destination d_dxall_unixstream {unix-stream("/var/run/logs/all.log");};
log {source(s_dxtcp); filter(f_request); destination(d_dxall_unixstream);};
When I restart my syslog-ng server, I have got the following message:
Connection failed; fd='11', server='AF_UNIX(/var/run/logs/all.log)',
local='AF_UNIX(anonymous)', error='Connection refused (111)'
Initiating connection failed, reconnecting; time_reopen='60'
What this error signifies? How can I use unix sockets with syslog-ng? Could any one help me out.
Till now I am not able to create a Unix Domain Socket for inter process communication. But I got a way around it. All I want is a one way communication to send data created at syslog-ng to a running java program(a process, I can say). This I achieved with Using Named Pipes in Syslog-ng. Documents for achieving is http://www.balabit.com/sites/default/files/documents/syslog-ng-ose-3.4-guides/en/syslog-ng-ose-v3.4-guide-admin/html-single/index.html#configuring-destinations-pipe .
Reading from Named Pipe is same as reading from a normal file. One important point to note is that Reader process(here the Java program) should be started before Syslog-ng, (Writer, that writes log messages to the Named pipe).
Reason, Writer will block until there is a Reader. Absence of Reader will lead to loss of some messages, that got accumulated before Reader Started. And there should be only one instance of Reader. If there are multiple readers, the second reader will get null pointer exception, as the message it want to read is already read by the first Reader. Kindly note that this is from my experience. Let me know, If I am wrong.