Symfony/Mailer 6.x with antiflood plugin? - symfony-mailer

In want replace deprecated SwiftMailer v6.2.5 with new Symfony/Mailer v6.x. SwiftMailer have a AntiFlood Plugin
$mailer = new Swift_Mailer($transport);
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 5));
I can't find this for Symfony/Mailer. Does this function(plugin) not yet exist or is this now solved in a completely different way?

Symfony Mailer 6.2 (current) has some parameters that might help to get similar approach as Swifmailer's AntiFlood plugin.
First, lets see how AntiFlood works. According to plugin's docs:
When Swift Mailer sends messages it will count the number of messages
that have been sent since the last re-connect. Once the number hits
your specified threshold it will disconnect and re-connect, optionally
pausing for a specified amount of time
// re-connect after 100 emails with 30 seconds pause in between
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30));
If we see official documentation of Symfony Mailer component. We can see some parameters that do exactly the same thing:
restart_threshold (Introduced in Symfony 5.2)
The maximum number of messages to send before re-starting the transport.
restart_threshold_sleep (Introduced in Symfony 5.2)
The number of seconds to sleep between stopping and re-starting the transport.
Here is an example using both parameters together:
$dsn = 'smtps://smtp.example.com?restart_threshold=1000&restart_threshold_sleep=30'
There are two more options in case you don't want to restart the transport, but instead just limit the amount of emails sent per second. See the documentation linked above if that's the case.

Related

Listener for IBM MQ

I am trying to create a listener for IBM MQ queue , to read message when its put to the queue using native API.
Is it better to use Thread/TimerTask to perform the GET every second.
I need to use the CCDT , username and password for the authentication purpose.
Is there any default listener available?
Reading from using below code
MQMessage theMessage = new MQMessage();
MQGetMessageOptions mqGetMessageOptions = new MQGetMessageOptions();
mqGetMessageOptions.options=MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
mqGetMessageOptions.matchOptions=MQC.MQMO_NONE;
mqGetMessageOptions.waitInterval=5000;
try{
//read the message from queue
queue.get(theMessage,mqGetMessageOptions);
mqGetMessageOptions.options = MQC.MQGMO_MSG_UNDER_CURSOR;
queue.get(theMessage, mqGetMessageOptions);
Your code is browse the messages and not consuming them (big difference).
Second, you should always use the MQC.MQGMO_FAIL_IF_QUIESCING option.
i.e.
mqGetMessageOptions.options=MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST | MQC.MQGMO_FAIL_IF_QUIESCING;
Third, do not use polling to access a queue - your thread/timer idea. It is a waste of resources. You already have a 5 second wait interval defined for the MQGET, if it is not long enough, then increase it to something more reasonable.
Finally, why did you tag this question with 'JMS'. There is nothing in your question related to JMS.

poplib mark as seen

I am using poplib in Python 3.3 to fetch emails from a gmail account and everything is working well, except that the mails are not marked as read after retrieving them with the retr() method, despite the fact that the documentation says "Retrieve whole message number which, and set its seen flag."
Here is the code:
pop = poplib.POP3_SSL("pop.gmail.com", "995")
pop.user("recent:mymail#gmail.com")
pop.pass_("mypassword")
numMessages = len(pop.list()[1])
for i in range(numMessages):
for j in pop.retr(i+1)[1]:
print(j)
pop.quit()
Am I doing something wrong or does the documentation lie? (or, did I just misinterpret it?)
The POP protocol has no concept of "read" or "unread" messages; the LIST command simply shows all existing messages. You may want to use another protocol, like IMAP, if the server supports it.
You could delete messages after successful retrieval, using the DELE command. Only after a successful QUIT command will the server actually delete them.

How does the .Exist timeout work within QTP?

I've worked with the .Exist method quite a bit, but I recently moved to a new project (now using a WPF application) with QTP 11 (whereas previously I had QTP 10).
Now I'd like to check that a message does not exist by using object.Exist(2). Weirdly, I only get a result after ~23 seconds, instead of the 2 seconds I was expecting.
How does the timeout work? In previous projects, using object.Exist(2) would wait 2 seconds before determining that the object didn't exist. The QTP help file also says it should only wait for 2 seconds (the specified timeout parameter).
Now, it seems as though it's waiting for the Timeout Parameter (2 seconds) AND Object Synchronization Timeout (20 seconds).
Also, Smart Identification is disabled, so it shouldn't be waiting for that. Highlighting the object using the Object Repository instantly says the object doesn't exist.
Has the timeout behavior changed between QTP v10 and v11?
Why does it take so long to say an object doesn't exist?
The Exist method does not work for the last object only.
It works hierarchically - which means this method checks each parent object before checking the last one.
The timeout only works for the last object.
if you want to receive the answer immediately, I suggest you use the following code-
if WPFWindow("x").Exist(0) Then
if WPFWindow("x").WPFButton("y").Exist(0) Then
'action
End if
End if
Make sure you don't have "Smart Identification" enabled for the test object in the Object Repository. That can get in the way.
The additional time that you're encountering is the default timeout setting, which is set to 20 seconds by default. Any Wait or Exist timers will stack on top of the default timeout.
It can be changed in the test settings:
Test Settings > Run > Object synchronization timeout - set in seconds
or in the vbscript:
Setting("DefaultTimeout") = 4000 'set in milliseconds
Using DefaultTimeout function at the beginning of the driver script would be sufficient .
Setting("DefaultTimeout") = 10000 'set in milliseconds
If any object exceeds the timeout limit of 10 seconds as mentioned above then the object will fail to get captured and Run Results will show a failure
I would recommend going by with just the default timeout. Using .Exist(x) will use the mentioned time for each child.

[Asterisk]Attended transfer using hook flash on a SIP channel

Within our organisation we use quite a few different models of telephone sets. The only thing they have in common, apart from the dialpad, is the ability to "send" hook flash. I prefer using this type of signaling for attended transfers above combinations of the usual dialpad keys to prevent the other end from receiving DTMF-tones (to prevent unwanted interactions with IVRs or bothering people on the other end).
2 questions:
How is a flash hook represented in features.conf? According to RFC2833 section 3.10 (DTMF Events) and this article (which is about a ZAP- instead of SIP-configuration, thus my doubt... see next question, also), it should be just "flash".
From my Google-quest I've learned that hook flash gets ignored by the PBX when using the SIP-protocol in Asterisk... I do get an error message when sending it: "WARNING[26159]: chan_sip.c:6487 sip_indicate: Don't know how to indicate condition 9". Is there a way to fix it/work around it?
Asterisk version: 1.8.3.2
Using "info" for dtmfmode
Tnx in advance!
In most cases you have in you adapter settings what to do with hook. IF you have, you can change that to transfer code.
Update: after code review i can say that DTMF 16 received ok and sended in 1.8.x. BUT features.c have no any action on flash(event 16)
So posible create audiohook application for asterisk to change that DTMF 16 to 2 DTMF values or invoke transfer. Will work for DTMF method SIPInfo, and such patch complexity is below-average(5-6 hours for expert)

How do you use CouchDB Change Notifications Continuous Changes from Java?

I am trying to use the couchdb (continuous) changes API from Java and find that after exhausting the list of current changes the stream seems to be closed, not stay open forever as it is supposed to.
The code I am using is below. I would expect to never drop out of the while loop, but do as soon as the currently existing changes are finished being streamed. I am relatively new to both couchdb and Java so may be missing something obvious. Can anyone show me how to write this correctly?
URL url = new URL("[path to database here]/_changes?feed=continuous";);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestMethod("GET");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while((line = reader.readLine()) != null){
// do something with the line here
}
// Should never get here under normal circumstances
reader.close();
There's actually a default timeout of 60000ms (60 seconds) unless a different timeout value or a heartbeat is provided. I updated the _changes wiki page back in October and included any defaults I came across in the code.
Setting the heartbeat basically means that you'll be watching for a timeout in the client, i.e. no newline for the heartbeat period means you've definitely lost your connection. I believe CouchDB disables its timeout check if there's a heartbeat.
In any case, you should probably expect the connection to be closed at some point and code for that condition.
You can use &heartbeat=1000 to get couchdb sending new lines over the wire every second. That will keep your connection open until you disconnect and/or CouchDB gets shut down.
But you are right, I would also have expected that the connection won't close - seems as if also conn.setReadTimeout(0); doesn't help anything.
This is just a guess since I dont know enough about the couchdb continuousfeed implementation or the HttpUrlConnection implementation. But it seems barring any bugs in the code of the two that if your java connection client has a timeout set lower than the default heartbeat for couchdb continuous changes then the connection could get terminated by the java client.
Just a thought.

Resources