LINUX.ORG.RU

Ответ на: комментарий от UnknownNPC
@Repository
public interface DeferredMessageRepository extends JpaRepository<DeferredMessage, Long> {
    List<DeferredMessage> getDeferredMessagesByRecipientAndSentOrderByCreatedAt(String recipient, Boolean sent);
}
bvn13 ★★★★★
() автор топика
Ответ на: комментарий от Deleted

очень. но в кишках не приходилось вплотную возиться

bvn13 ★★★★★
() автор топика
Ответ на: комментарий от UnknownNPC

Мессага унаследована от базовой сущности

@MappedSuperclass
public abstract class BaseModel implements Comparable<BaseModel>, Serializable {

    @Getter
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Getter
    @Setter
    @Column(nullable = false)
    private Date createdAt;

    @Getter
    @Setter
    @Column(nullable = false)
    private Date updatedAt;

    @PrePersist
    public void prePersist(){
        createdAt = updatedAt = new Date();
    }

    @PreUpdate
    public void preUpdate(){
        updatedAt = new Date();
    }

    @Override
    public int compareTo(BaseModel o) {
        return this.getId().compareTo(o.getId());
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }
}

При сохранении в консоль пишется только

2018-01-31 20:54:19.255 [listenerPool0-thread3] DEBUG o.s.d.r.c.s.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource - Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''

bvn13 ★★★★★
() автор топика
Последнее исправление: bvn13 (всего исправлений: 1)
Ответ на: комментарий от bvn13

Есть возможность дать исходники? А то можно только гадать.

Я бы еще попробовал добавить `@Transactional` над методом сервиса.

UnknownNPC
()
Ответ на: комментарий от bvn13

Неа, у тебя там говнокод:

Thread 1: (state = IN_NATIVE)
 - java.net.SocketInputStream.socketRead0(java.io.FileDescriptor, byte[], int, int, int) @bci=0 (Compiled frame; information may be imprecise)
 - java.net.SocketInputStream.socketRead(java.io.FileDescriptor, byte[], int, int, int) @bci=8, line=116 (Compiled frame)
 - java.net.SocketInputStream.read(byte[], int, int, int) @bci=117, line=171 (Compiled frame)
 - java.net.SocketInputStream.read(byte[], int, int) @bci=11, line=141 (Compiled frame)
 - sun.nio.cs.StreamDecoder.readBytes() @bci=135, line=284 (Interpreted frame)
 - sun.nio.cs.StreamDecoder.implRead(char[], int, int) @bci=112, line=326 (Interpreted frame)
 - sun.nio.cs.StreamDecoder.read(char[], int, int) @bci=180, line=178 (Interpreted frame)
 - java.io.InputStreamReader.read(char[], int, int) @bci=7, line=184 (Interpreted frame)
 - java.io.BufferedReader.fill() @bci=145, line=161 (Interpreted frame)
 - java.io.BufferedReader.readLine(boolean) @bci=44, line=324 (Compiled frame)
 - java.io.BufferedReader.readLine() @bci=2, line=389 (Compiled frame)
 - org.pircbotx.PircBotX.processNextLine() @bci=4, line=309 (Interpreted frame)
 - org.pircbotx.PircBotX.startLineProcessing() @bci=1, line=295 (Interpreted frame)
 - org.pircbotx.PircBotX.connect() @bci=872, line=284 (Interpreted frame)
 - org.pircbotx.PircBotX.startBot() @bci=31, line=177 (Interpreted frame)
 - ru.bvn13.jircbot.bot.JircBot.lambda$start$1(java.lang.String, org.pircbotx.PircBotX) @bci=1, line=116 (Interpreted frame)
 - ru.bvn13.jircbot.bot.JircBot$$Lambda$21.accept(java.lang.Object, java.lang.Object) @bci=8 (Interpreted frame)
 - java.util.HashMap.forEach(java.util.function.BiConsumer) @bci=65, line=1289 (Interpreted frame)
 - ru.bvn13.jircbot.bot.JircBot.start() @bci=70, line=114 (Interpreted frame)

Оно за какимто лядом (?) синхронно лезет в сеть и есесно блокируется при старте бина. И тем самым лочит запуск приложения.

ps. а то что 28 поток заблокирован - это уже следствие, вот этого вот что я привёл.

Deleted
()
Последнее исправление: Deleted (всего исправлений: 1)
Ответ на: комментарий от bvn13

Если написать тест для «DeferredMessageService.saveDeferredMessage(...)», то он отлично справляется со своими обязательствами.

А так, мы, походу, зависаем внутри «while» туточки:

- org.pircbotx.PircBotX.processNextLine() @bci=4, line=309 (Interpreted frame)
- org.pircbotx.PircBotX.startLineProcessing() @bci=1, line=295 (Interpreted frame)

protected void startLineProcessing() {
	while (processNextLine()) {
		//see processNextLine
	}
}

Может в него кто-то что-то уверено пишет после коннекта?

UnknownNPC
()
Ответ на: комментарий от UnknownNPC

все верно! библа бота блокирует thread. решилось запуском в отдельном треде

@PostConstruct
    public void postConstruct() {
        this.executorService = Executors.newSingleThreadScheduledExecutor();
        this.executorService.schedule(new Runnable() {
            @Override
            public void run() {
                start();
            }
        }, 5, TimeUnit.SECONDS);
    }


    public void start() {

        logger.info(">>>>>>>>>>>>>>>>>>>> BOT STARTING <<<<<<<<<<<<<<<<<<<<");

        //Setup this bot
        Configuration.Builder templateConfig = new Configuration.Builder()
                .setLogin("JIrcBot") //login part of hostmask, eg name:login@host
                .setAutoNickChange(true) //Automatically change nick when the current one is in use
                .setCapEnabled(true) //Enable CAP features
                .addCapHandler(new TLSCapHandler(new UtilSSLSocketFactory().trustAllCertificates(), true));

        this.config.getConnections().forEach(c -> {
            List<Configuration.ServerEntry> servers = new ArrayList<>();
            servers.add(new Configuration.ServerEntry(c.getServer(), c.getPort()));
            this.bots.put(
                    String.format("%s/%s", c.getServer(), "1"),
                    new PircBotX(templateConfig
                            .setName(c.getBotName())
                            .setServers(servers)
                            .setAutoReconnect(true)
                            .addAutoJoinChannels(c.getChannelsNames())
                            .buildForServer(c.getServer())
                    )
            );
        });

        //bot.connect throws various exceptions for failures
        this.bots.forEach((id, b) -> {
            try {
                b.startBot();
            } catch (Exception ex) {
                logger.error("ERROR STARTING BOT: "+id);
                ex.printStackTrace();
            }
        });

    }
bvn13 ★★★★★
() автор топика
Ответ на: комментарий от Deleted

это не мой :) это от PircBotX досталось. а решение я нашел. смотри чуть выше.

bvn13 ★★★★★
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.