Redelivery is ignored in ActiveMQ Artemis 2.4.0 - configuration

I configured Artemis to redeliver faild messages like this (broker.xml):
<address-setting match="#">
<dead-letter-address>DLQ</dead-letter-address>
<expiry-address>ExpiryQueue</expiry-address>
<!-- with -1 only the global-max-size is in use for limiting -->
<max-size-bytes>-1</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<auto-create-queues>true</auto-create-queues>
<auto-create-addresses>true</auto-create-addresses>
<auto-create-jms-queues>true</auto-create-jms-queues>
<auto-create-jms-topics>true</auto-create-jms-topics>`enter code here`
<max-delivery-attempts>3</max-delivery-attempts>
<redelivery-delay>30000</redelivery-delay>
<max-redelivery-delay>30000</max-redelivery-delay>
</address-setting>
[...]
<address-setting match="email">
<redelivery-delay-multiplier>3</redelivery-delay-multiplier>
<redelivery-delay>60000</redelivery-delay>
<max-redelivery-delay>86400000</max-redelivery-delay>
</address-setting>
[...]
<addresses>
<address name="email">
<anycast>
<queue name="email" />
</anycast>
</address>
</addresses>
I use Springboot as sender and receiver. After sending a message to the queue it appears in artemis' queue and the receiver is called. The processing fails. But instead of putting the message back to the queue and try to redeliver it, this happens:
09:57:37,672 WARN [org.apache.activemq.artemis.core.server] AMQ222149: Message Reference[53]:RELIABLE:CoreMessage[messageID=53,durable=true,userID=null,priority=4, timestamp=Mon Jan 29 09:57:37 UTC 2018,expiration=0, durable=
true, address=email,properties=TypedProperties[__HDR_dlqDeliveryFailureCause=java.lang.Throwable: Delivery[1] exceeds redelivery policy limit:RedeliveryPolicy {destination = null, collisionAvoidanceFactor = 0.15, maximumRedeli
veries = 0, maximumRedeliveryDelay = -1, initialRedeliveryDelay = 1000, useCollisionAvoidance = false, useExponentialBackOff = false, backOffMultiplier = 5.0, redeliveryDelay = 1000, preDispatchCheck = true}, cause:null,__HDR_
BROKER_IN_TIME=1517219857591,interaction_id=b0b5cb2c618f4605a11ad599dfd7f54b,_AMQ_ROUTING_TYPE=1,__HDR_ARRIVAL=0,__HDR_GROUP_SEQUENCE=0,__HDR_COMMAND_ID=36,__HDR_MARSHALL_PROP=[0000 0001 000E 696E 7465 7261 6374 696F 6E5F 6964
0900 2062 3062 3563 6232 6336 3138 6634 3630 3561 3131 6164 3539 3964 6664 3766 3534 62),__HDR_PRODUCER_ID=[0000 003D 7B01 0029 4944 3A64 652D 6164 6E2D 6266 786A 6E63 322D 3532 3232 ... 37 3231 3934 3238 3032 362D 313A 3100
0000 0000 0000 0100 0000 0000 0000 09),_AMQ_DUPL_ID=ID:de-adn-bfxjnc2-52228-1517219428026-1:1:9:1:3,__HDR_MESSAGE_ID=[0000 0050 6E00 017B 0100 2949 443A 6465 2D61 646E 2D62 6678 6A6E 6332 2D35 ... 0000 0000 0001 0000 0000 0
000 0009 0000 0000 0000 0003 0000 0000 0000 0000),__HDR_DROPPABLE=false]]#693556289 has reached maximum delivery attempts, sending it to Dead Letter Address DLQ from email
It looks to me as if my configuration is completely ignored.
Can anybody tell me, what is wron in my configuration?

Related

Error while using cenpy library in python

I am working on a project where I need to use census data for a couple of towns in MA. For that, I am using cenpy library ASC data, but I got a key error. The same error happens even when I try the example code described for Chicago. Here is the example code I use and the error I see:
chicago = products.ACS(2017).from_place('Chicago, IL', level='tract',
variables=['B00002*', 'B01002H_001E'])
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~\anaconda3\envs\oxe\lib\site-packages\cenpy\tiger.py:192, in ESRILayer.query(self, raw, strict, **kwargs)
191 try:
--> 192 features = datadict["features"]
193 except KeyError:
KeyError: 'features'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 chicago = products.ACS(2017).from_place('Chicago, IL', level='tract',
2 variables=['B00002*', 'B01002H_001E'])
File ~\anaconda3\envs\oxe\lib\site-packages\cenpy\products.py:791, in ACS.from_place(self, place, variables, level, return_geometry, place_type, strict_within, return_bounds, replace_missing)
788 variables = self._preprocess_variables(variables)
789 variables.append("GEO_ID")
--> 791 geoms, variables, *rest = super(ACS, self).from_place(
792 place,
793 variables=variables,
794 level=level,
795 return_geometry=return_geometry,
796 place_type=place_type,
797 strict_within=strict_within,
798 return_bounds=return_bounds,
799 replace_missing=replace_missing,
800 )
801 variables["GEOID"] = variables.GEO_ID.str.split("US").apply(lambda x: x[1])
802 return_table = geoms[["GEOID", "geometry"]].merge(
803 variables.drop("GEO_ID", axis=1), how="left", on="GEOID"
804 )
File ~\anaconda3\envs\oxe\lib\site-packages\cenpy\products.py:200, in _Product.from_place(self, place, variables, place_type, level, return_geometry, geometry_precision, strict_within, return_bounds, replace_missing)
197 else:
199 placer = "STATE={} AND PLACE={}".format(placerow.STATEFP, placerow.TARGETFP)
--> 200 env = env_layer.query(where=placer)
202 print(
203 "Matched: {} to {} "
204 "within layer {}".format(
(...)
208 )
209 )
211 geoms, data = self._from_bbox(
212 env.to_crs(epsg=4326).total_bounds,
213 variables=variables,
(...)
219 replace_missing=replace_missing,
220 )
File ~\anaconda3\envs\oxe\lib\site-packages\cenpy\tiger.py:198, in ESRILayer.query(self, raw, strict, **kwargs)
196 if details is []:
197 details = "Mapserver provided no detailed error"
--> 198 raise KeyError(
199 (
200 r"Response from API is malformed. You may have "
201 r"submitted too many queries, formatted the request incorrectly, "
202 r"or experienced significant network connectivity issues."
203 r" Check to make sure that your inputs, like placenames, are spelled"
204 r" correctly, and that your geographies match the level at which you"
205 r" intend to query. The original error from the Census is:\n"
206 r"(API ERROR {}:{}({}))".format(code, msg, details)
207 )
208 )
209 todf = []
210 for i, feature in enumerate(features):
KeyError: 'Response from API is malformed. You may have submitted too many queries, formatted the request incorrectly, or experienced significant network connectivity issues. Check to make sure that your inputs, like placenames, are spelled correctly, and that your geographies match the level at which you intend to query. The original error from the Census is:\\n(API ERROR 400:Unable to complete operation.([]))'

Mutilple JSON root element errors

The file I am calling is JSON with padding and I have done my simple coding to remove the padding but it appears by stringing together multiple JSON strings the formatting is not correct and I get root element errors.
I am using the output of the python program and running it through an online JSON formatter and validator website to check my output. I am a learner so please bear with my inexperience. All help appreciated.
import json
import re
import requests
payload = {}
headers = {}
for race in range(1, 3):
url = f"https://s3-ap-southeast-2.amazonaws.com/racevic.static/2018-01-01/flemington/sectionaltimes/race-{race}.json?callback=sectionaltimes_callback"
response = requests.request("GET", url, headers=headers, data=payload)
strip = 'sectionaltimes_callback'
string = response.text
repl =''
result = re.sub(strip, repl, string)
print(result)
This is one way of obtaining the data you're looking for:
import requests
import json
import pandas as pd
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0',
'Accept-Language' : 'en-US,en;q=0.5'}
for race in range(1, 3):
url = f"https://s3-ap-southeast-2.amazonaws.com/racevic.static/2018-01-01/flemington/sectionaltimes/race-{race}.json?callback=sectionaltimes_callback"
r = requests.get(url, headers=headers)
json_obj = json.loads(r.text.split('sectionaltimes_callback(')[1].rsplit(')', 1)[0])
df = pd.DataFrame(json_obj['Horses'])
print(df)
This would return (print out in terminal) a dataframe for each race:
Comment FinalPosition FinalPositionAbbreviation FullName SaddleNumber HorseUrl SilkUrl Trainer TrainerUrl Jockey ... DistanceVarToWinner SixHundredMetresTime TwoHundredMetresTime Early Mid Late OverallPeakSpeed PeakSpeedLocation OverallAvgSpeed DistanceFromRail
0 Resumes. Showed pace to lead well off the rail... 1 1st Crossing the Abbey 2 /horses/crossing-the-abbey //s3-ap-southeast-2.amazonaws.com/racevic.silk... T.Hughes /trainers/tim-hughes C.Williams ... 32.84 11.43 57.4 68.2 65.3 68.9 400m 63.3 0.8
1 Same sire as Katy's Daughter out of dual stake... 2 2nd Khulaasa 5 /horses/khulaasa //s3-ap-southeast-2.amazonaws.com/racevic.silk... D. & B.Hayes & T.Dabernig /trainers/david-hayes D.Oliver ... 0 32.61 11.29 56.6 68.4 66.0 69.2 700m 63.4 1.2
2 Trialled nicely before pleasing debut in what ... 3 3rd Graceful Star 4 /horses/graceful-star //s3-ap-southeast-2.amazonaws.com/racevic.silk... D. & B.Hayes & T.Dabernig /trainers/david-hayes A.Mallyon ... 0 33.10 11.56 56.9 67.4 64.8 68.5 400m 62.8 4.4
3 Sat second at debut, hampered at the 700m then... 4 4th Carnina 1 /horses/carnina //s3-ap-southeast-2.amazonaws.com/racevic.silk... T.Busuttin & N.Young /trainers/trent-busuttin B.Mertens ... +1 33.30 11.80 56.9 68.2 63.9 68.9 400m 62.7 3.0
4 $75k yearling by a Magic Millions winner out o... 5 5th Mirette 7 /horses/mirette //s3-ap-southeast-2.amazonaws.com/racevic.silk... A.Alexander /trainers/archie-alexander J.Childs ... 0 33.53 11.89 57.0 67.9 63.5 68.5 700m 62.5 3.8
5 $95k yearling by same sire as Pinot out of a s... 6 6th Dark Confidant 3 /horses/dark-confidant //s3-ap-southeast-2.amazonaws.com/racevic.silk... D. & B.Hayes & T.Dabernig /trainers/david-hayes D.Dunn ... +2 33.74 11.91 56.4 67.1 63.3 68.8 700m 61.9 5.0
6 Same sire as Vega Magic out of imported stakes... 7 7th La Celestina 6 /horses/la-celestina //s3-ap-southeast-2.amazonaws.com/racevic.silk... D.R.Brideoake /trainers/david-brideoake D.M.Lane ... +1 34.46 12.27 57.5 67.3 61.4 68.2 700m 61.7 0.8
7 rows × 29 columns
Comment FinalPosition FinalPositionAbbreviation FullName SaddleNumber HorseUrl SilkUrl Trainer TrainerUrl Jockey ... DistanceVarToWinner SixHundredMetresTime TwoHundredMetresTime Early Mid Late OverallPeakSpeed PeakSpeedLocation OverallAvgSpeed DistanceFromRail
0 Game in defeat both runs this campaign. Better... 1 1st Wise Hero 2 /horses/wise-hero //s3-ap-southeast-2.amazonaws.com/racevic.silk... J.W.Price /trainers/john-price S.M.Thornton ... 33.13 11.43 55.4 62.7 65.5 68.2 300m 61.7 0.7
1 Two runs since racing wide over this trip at C... 2 2nd Just Hifalutin 5 /horses/just-hifalutin //s3-ap-southeast-2.amazonaws.com/racevic.silk... E.Jusufovic /trainers/enver-jusufovic L.Currie ... +3 32.75 11.37 53.1 63.8 65.8 68.5 400m 61.7 3.3
2 Did a bit of early work at Seymour and was not... 3 3rd King Kohei 10 /horses/king-kohei //s3-ap-southeast-2.amazonaws.com/racevic.silk... Michael & Luke Cerchi /trainers/mick-cerchi
[...]

Python OCR Tesseract, find a certain word in the image and return me the coordinates

I wanted your help, I've been trying for a few months to make a code that finds a word in the image and returns the coordinates where that word is in the image.
I was trying this using OpenCV, OCR tesseract, but I was not successful, could someone here in the community help me?
I'll leave an image here as an example:
Here is something you can start with:
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r'C:\<path-to-your-tesseract>\Tesseract-OCR\tesseract.exe'
img = Image.open("img.png")
data = pytesseract.image_to_data(img, output_type='dict')
boxes = len(data['level'])
for i in range(boxes):
if data['text'][i] != '':
print(data['left'][i], data['top'][i], data['width'][i], data['height'][i], data['text'][i])
If you have difficulties with installing pytesseract see: https://stackoverflow.com/a/53672281/18667225
Output:
153 107 277 50 Palavras
151 197 133 37 com
309 186 154 48 R/RR
154 303 126 47 Rato
726 302 158 47 Resto
154 377 144 50 Rodo
720 379 159 47 Arroz
152 457 160 48 Carro
726 457 151 46 Ferro
154 532 142 50 Rede
726 534 159 47 Barro
154 609 202 50 Parede
726 611 186 47 Barata
154 690 124 47 Faro
726 685 288 50 Beterraba
154 767 192 47 Escuro
726 766 151 47 Ferro
I managed to find the solution and I'll post it here for you:
import pytesseract
import cv2
from pytesseract import Output
pytesseract.pytesseract.tesseract_cmd = r'C:\<path-to-your-tesseract>\Tesseract-OCR\tesseract.exe'
filepath = 'image.jpg'
image = cv2.imread(filepath, 1)
# converting image to grayscale image
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# converting to binary image by Thresholding
# this step is necessary if you have a color image because if you skip this part
# then the tesseract will not be able to detect the text correctly and it will give an incorrect result
threshold_img = cv2.threshold(gray_image, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
# displays the image
cv2.imshow('threshold image', threshold_img)
# Holds the output window until the user presses a key
cv2.waitKey(0)
# Destroying windows present on the screen
cv2.destroyAllWindows()
# setting parameters for tesseract
custom_config = r'--oem 3 --psm 6'
# now feeding image to tesseract
details = pytesseract.image_to_data(threshold_img, output_type=Output.DICT, config=custom_config, lang='eng')
# Color
vermelho = (0, 0, 255)
#Exibe todas as chaves encontradas
print(details.keys())
print(details['text'])
# For in all found texts
for i in range(len(details['text'])):
# If it finds the text "UNIVERIDADE" it will print the coordinates, and draw a rectangle around the word
if details['text'][i] == 'UNIVERSIDADE':
print(details['text'][i])
print(f"left: {details['left'][i]}")
print(f"top: {details['top'][i]}")
print(f"width: {details['width'][i]}")
print(f"height: {details['height'][i]}")
cv2.rectangle(image, (details['left'][i], details['top'][i]), (details['left'][i]+details['width'][i], details['top'][i]+details['height'][i]), vermelho)

WebUSB limitation controlTransferOut?

I used usbmon to analyse usb packets, and implement it in webusb however I wasn't able to find a solution for this. This is what Sane send to usb :
S Co:1:074:0 s 02 01 0000 0081 0000 0
C Co:1:074:0 0 0
S Co:1:074:0 s 02 01 0000 0002 0000 0
C Co:1:074:0 0 0
Which is similar to a controlTransferOut() command, with requestType=Standard, recipient: 'endpoint', request: 1, index: 0x00, value:129
The 'value' here is very tricky since all other parameters should be correct according to documentation, however sending value:129 should send something like :
S Co:1:074:0 s 02 01 0081 0000 0000 0
However what I got instead is :
Uncaught (in promise) DOMException: The specified endpoint number is out of range.
While value is an unsigned short, which is max 0xffff ! So obviously value should be 0, and next nibble 0x0081. My question is how to trigger a Control Output (Co) with value in second nibble ?
The code is something like this :
navigator.usb.requestDevice({ filters: [{ vendorId: 0x1083}] })
.then(selectedDevice => {
device = selectedDevice;
return device.open(); // Begin a session.
})
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(0))
.then(() => device.controlTransferOut({
requestType: 'standard',
recipient: 'endpoint',
request: 0x00,
value: 129,
index: 0x00}))
All other combinations are sent with response "Stall" for example (class, interface : 21 - vendor, device : 40 ...etc).
Device description and Endpoint descriptor are available here
Thank you
Just found it, request should be :
device.controlTransferOut({
requestType: 'standard',
recipient: 'endpoint',
request: 1,
value: 0,
index: 129})
This give :
S Co:1:075:0 s 02 01 0000 0081 0000 0
C Co:1:075:0 0 0
Which is exactly what I need.

using expect to send a single byte

Have a tcl expect connection to a telnetd and want to send the telnet BREAK.
There for the telnetd must be informend to go into command mode. So the IAC (255) hast to be sende.
After this BRK(243) has to be send.
I verifyed this with a putty->telnetd connection. Putty can send "BREAK". The network traffic shows what is expected 255/243
When I send ICA(255)/BRK(243) with tcl expect I see in the network traffic, that three bytes (255/255/243) were send.
I found out when I send i.e. 254 I see one byte
When I send 255. It is two bytes.
I expect 255, which is -1 or ff has someting special in expect.
How can I achive to get just 255 onto the wire?
fconfigure $channel -translation
exp_send -i $channel -- [binary format H4 FFF3]
This sends "ff ff f3" to the telnetd
As mention in the responce, yes, the language has to be taken into account. So I add fconfigure to have none
Here is my code:
package require Expect
spawn telnet localhost
fconfigure $spawn_id -translation binary
exp_send "[binary format H4 FFf3]"
after 2000
When I look on the wire with tcpdump -X -i localhost port 23 I see FFFFF3.
11:26:10.358187 IP localhost.44802 > localhost.telnet: Flags [P.], seq 129:132, ack 148, win 342, options [nop,nop,TS val 1826173122 ecr 1826168178], length 3
0x0000: 4510 0037 835b 4000 4006 b953 7f00 0001 E..7.[#.#..S....
0x0010: 7f00 0001 af02 0017 b004 9eec f815 49e3 ..............I.
0x0020: 8018 0156 fe2b 0000 0101 080a 6cd9 30c2 ...V.+......l.0.
0x0030: 6cd9 1d72 ffff f3
I look into telnet with strace and see:
203 27482 12:37:28 read(0, "\377\363", 8192) = 2
204 27482 12:37:28 select(4, [0 3], [3], [3], {0, 0}) = 1 (out [3], left {0, 0})
205 27482 12:37:28 sendto(3, "\377\377\363", 3, 0, NULL, 0) = 3
fff3 is received by expect, ff ff f3 is send to the telnetd.
I was totally wrong with my toughts.
Because I use "telnet" spawned within expect, I have to send "CTRL]" "send brk\r".
And everything is fine.