Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / Spring Amqp+Rabbit / 5 сообщений из 5, страница 1 из 1
28.12.2018, 17:31
    #39754656
Озверин
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Spring Amqp+Rabbit
Какое-то время назад у кролика появилась фича складиварования мертвых сообщений в отдельную очередь. https://www.rabbitmq.com/dlx.html

Как средствами из шапки реализовать следующий маршрут: workingQueue->deadLetterQueue->workingQueue?
Моя идея была такова:

В аргументе рабочей очереди указать exchager по умолчанию, на который кидаются сообщения с ошибками :

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
 @Bean
  public Queue workingQueue() {
    return QueueBuilder
        .durable(requestQueue)
        .withArgument("x-dead-letter-exchange", "")
        .withArgument("x-dead-letter-routing-key", deadRequestQueue)
        .withArgument("x-message-ttl", ttl)
        .build();
  }



И в свою очередь в deadQueue указать ttl и кидать оттуда по expired в рабочий exchanger


Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
@Bean
  public Queue deadLetterQueue() {
    return QueueBuilder
        .durable(deadRequestQueue)
        .withArgument("x-dead-letter-exchange", requestExchange)
        .withArgument("x-dead-letter-routing-key", requestRoutingKey)
        .withArgument("x-message-ttl", ttl)
        .withArgument("x-queue-mode", "lazy")
        .build();
  }



Сообщения по истечению ttl`а - попадают в deadRequestQueue с ключом равным - deadRequestQueue
Но из мертвой очереди они уже никуда не попадают.
...
Рейтинг: 0 / 0
28.12.2018, 19:38
    #39754694
Герой дня
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Spring Amqp+Rabbit
Озверин,

потому что мертвую очередь никто не обрабатывает ?

вообще, есть Spring Cloud Stream - там подобное делается настройками в application.yml
...
Рейтинг: 0 / 0
29.12.2018, 09:15
    #39754795
Озверин
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Spring Amqp+Rabbit
Герой дня, так эта очередь в теории и не должна обрабатываться, даже не должна - у нее ttl и кажецо, что после истечения должно кинуться на exchanger из аргумента.
...
Рейтинг: 0 / 0
29.12.2018, 09:19
    #39754796
nastyaa
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Spring Amqp+Rabbit
Герой дня,

Можешь подсказать как работает toupperstring в этом коде

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
package kz.nic.converter;


import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author admin
 */
public class KazakhLatinConverter {

    private final Map<String, String> dictionary = new HashMap();

    public KazakhLatinConverter() {
        fillDictionary();
    }

    /**
     * 
     * @param str
     * @return 
     */
    public String convert(String str) {        
        char[] chars = str.toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            char currentChar = chars[i];
            String currentString = Character.toString(currentChar);
            if (dictionary.containsKey(currentString)) {
                String translatedString = dictionary.get(currentString);

                if (Character.isUpperCase(currentChar)) {
                    boolean toUpperCase = false;
                    if (i + 1 < chars.length) {
                        char nextChar = chars[i + 1];
                        if (Character.isUpperCase(nextChar)) {
                            toUpperCase = true;
                        }

                    } else {
                        toUpperCase = true;
                    }
                    if (toUpperCase) {
                        translatedString = translatedString.toUpperCase();
                    }
                }

                stringBuilder.append(translatedString);
                continue;
            }
            stringBuilder.append(currentString);
        }
        return stringBuilder.toString();
    }
    
    /**
     * 
     */
    private void fillDictionary() {
        dictionary.put("а", "a");
        dictionary.put("А", "A");
        dictionary.put("&#1241;", "&#225;");
        dictionary.put("&#1240;", "&#193;");
        dictionary.put("б", "b");
        dictionary.put("Б", "B");
        dictionary.put("д", "d");
        dictionary.put("Д", "D");
        dictionary.put("е", "e");
        dictionary.put("Е", "E");
        dictionary.put("ё", "&#305;o");
        dictionary.put("Ё", "IO");
        dictionary.put("ф", "f");
        dictionary.put("Ф", "F");
        dictionary.put("г", "g");
        dictionary.put("Г", "G");
        dictionary.put("&#1171;", "&#501;");
        dictionary.put("&#1170;", "&#500;");
        dictionary.put("х", "h");
        dictionary.put("Х", "H");
        dictionary.put("&#1211;", "h");
        dictionary.put("&#1210;", "H");
        dictionary.put("і", "i");
        dictionary.put("І", "I");
        dictionary.put("и", "&#305;");
        dictionary.put("И", "I");
        dictionary.put("й", "&#305;");
        dictionary.put("Й", "I");
        dictionary.put("ж", "j");
        dictionary.put("Ж", "J");
        dictionary.put("к", "k");
        dictionary.put("К", "K");
        dictionary.put("л", "l");
        dictionary.put("Л", "L");
        dictionary.put("м", "m");
        dictionary.put("М", "M");
        dictionary.put("н", "n");
        dictionary.put("Н", "N");
        dictionary.put("&#1187;", "&#324;");
        dictionary.put("&#1186;", "&#323;");
        dictionary.put("о", "o");
        dictionary.put("О", "O");
        dictionary.put("&#1257;", "&#243;");
        dictionary.put("&#1256;", "&#211;");
        dictionary.put("п", "p");
        dictionary.put("П", "P");
        dictionary.put("&#1179;", "q");
        dictionary.put("&#1178;", "Q");
        dictionary.put("р", "r");
        dictionary.put("Р", "R");
        dictionary.put("с", "s");
        dictionary.put("С", "S");
        dictionary.put("ш", "sh");
        dictionary.put("Ш", "Sh");
        dictionary.put("ч", "ch");
        dictionary.put("Ч", "Ch");
        dictionary.put("т", "t");
        dictionary.put("Т", "T");
        dictionary.put("&#1199;", "&#250;");
        dictionary.put("&#1198;", "&#218;");
        dictionary.put("&#1201;", "u");
        dictionary.put("&#1200;", "U");
        dictionary.put("в", "v");
        dictionary.put("В", "V");
        dictionary.put("ы", "y");
        dictionary.put("Ы", "Y");
        dictionary.put("у", "&#253;");
        dictionary.put("У", "&#221;");
        dictionary.put("з", "z");
        dictionary.put("З", "Z");
        dictionary.put("э", "e");
        dictionary.put("Э", "E");
        dictionary.put("ю", "&#305;&#253;");
        dictionary.put("Ю", "I&#253;");
        dictionary.put("я", "&#305;a");
        dictionary.put("Я", "Ia");
        dictionary.put("ь", "");
        dictionary.put("Ь", "");
        dictionary.put("ъ", "");
        dictionary.put("Ъ", "");
        dictionary.put("ц", "ts");
        dictionary.put("Ц", "Ts");
        dictionary.put("щ", "sh");
        dictionary.put("Щ", "Sh");
    }
}
...
Рейтинг: 0 / 0
29.12.2018, 13:25
    #39754909
Герой дня
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Spring Amqp+Rabbit
nastyaa,

сори, большой код, надо разбираться.. пока некогда
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / Spring Amqp+Rabbit / 5 сообщений из 5, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]