我刚刚下载了弹性搜索分发并运行它.
curl 'localhost:9200'
{
"status" : 200,
"name" : "cbs",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.4.1",
"build_hash" : "89d3241d670db65f994242c8e8383b169779e2d4",
"build_timestamp" : "2014-11-26T15:49:29Z",
"build_snapshot" : false,
"lucene_version" : "4.10.2"
},
"tagline" : "You Know, for Search"
}
Run Code Online (Sandbox Code Playgroud)
我试图使用spring-data访问它.在应用程序上下文中(根据spring数据文档)在xml命名空间中添加了以下行:
<elasticsearch:repositories base-package="com.cbs" />
<elasticsearch:transport-client id="client" cluster-nodes="127.0.0.1:9300" cluster-name="elasticsearch" />
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="client" />
</bean>
Run Code Online (Sandbox Code Playgroud)
这是实体和存储库代码:
@org.springframework.data.elasticsearch.annotations.Document(indexName = "product", type = "product", shards = 1, replicas = 0, indexStoreType = "memory", refreshInterval = "-1")
public class Product {
@Id …Run Code Online (Sandbox Code Playgroud) 我有一个测试类加载测试spring应用程序上下文,现在我想创建一个junit规则,它将在mongo db中设置一些测试数据.为此,我创建了一个规则类.
public class MongoRule<T> extends ExternalResource {
private MongoOperations mongoOperations;
private final String collectionName;
private final String file;
public MongoRule(MongoOperations mongoOperations, String file, String collectionName) {
this.mongoOperations = mongoOperations;
this.file = file;
this.collectionName = collectionName;
}
@Override
protected void before() throws Throwable {
String entitiesStr = FileUtils.getFileAsString(file);
List<T> entities = new ObjectMapper().readValue(entitiesStr, new TypeReference<List<T>>() {
});
entities.forEach((t) -> {
mongoOperations.save(t, collectionName);
});
}
}
Run Code Online (Sandbox Code Playgroud)
现在我在我的测试类中使用这个规则并传递mongoOperations bean.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringTestConfiguration.class)
public class TransactionResourceTest {
@Autowired
private ITransactionResource transactionResource;
@Autowired …Run Code Online (Sandbox Code Playgroud) 我使用 ActiveMQ 来排队电子邮件消息,消费者读取队列并发送电子邮件。
在启动时,我注册了一个生产者并永久缓存它。
PooledConnectionFactory factory = new PooledConnectionFactory(new ActiveMQConnectionFactory(jmsBrokerUserName, jmsBrokerPassword, activeMQBrokerURL));
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(queueName);
MessageProducer producer = session.createProducer(destination);
Run Code Online (Sandbox Code Playgroud)
有时,当连接关闭时,生产者无法将消息加入队列。
Caused by: javax.jms.IllegalStateException: The Session is closed
at org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:767) ~[activemq-client-5.10.0.jar:5.10.0]
at org.apache.activemq.ActiveMQSession.configureMessage(ActiveMQSession.java:755) ~[activemq-client-5.10.0.jar:5.10.0]
at org.apache.activemq.ActiveMQSession.createTextMessage(ActiveMQSession.java:438) ~[activemq-client-5.10.0.jar:5.10.0]
at org.apache.activemq.jms.pool.PooledSession.createTextMessage(PooledSession.java:242) ~[activemq-jms-pool-5.10.0.jar:5.10.0]
Run Code Online (Sandbox Code Playgroud)
有人可以让我知道处理封闭式会议的最佳方法是什么吗?我应该重新注册我的生产者吗?或者有没有办法重新打开会话?
我正在使用Spring websocket实现.要向客户端发送消息,有两种方法:
1)使用@SendToUser注释
2)使用convertAndSendToUser方法SimpMessagingTemplate
@SendToUser获取一个布尔参数broadcast,如果设置为false,则将该消息发布到当前会话.有没有办法让我有这种行为SimpMessagingTemplate.
我希望通过侦听 DocumentDB 更改流,通过 lambda 函数填充 SQS 队列。我知道这可以通过DynamoDB来完成。有没有办法用 DocumentDB 来实现这一点?
我是Elasticsearch的新手。我有一个筛选查询,使用控制台可以为我提供正确的结果:
GET _search
{
"query": {
"filtered": {
"query": {
"bool" : {
"should" : [
{
"match" : { "name" : "necklace" }
},
{
"match" : { "skuCode" : "necklace" }
}
]
}
},
"filter": {
"bool" : {
"must" : [
{
"term" : { "enabled" : true }
},
{
"term" : { "type" : "SIMPLE" }
},
{
"term" : { "tenantCode" : "Triveni" }
}
]
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我无法获得相应的spring-data版本。这是我尝试过的:
SearchQuery …Run Code Online (Sandbox Code Playgroud) 某些附件大于 2MB 的电子邮件会发生这种情况。
我得到的堆栈跟踪是这样的:
com.sun.mail.util.FolderClosedIOException
at com.sun.mail.imap.IMAPInputStream.forceCheckExpunged(IMAPInputStream.java:107)
at com.sun.mail.imap.IMAPInputStream.fill(IMAPInputStream.java:158)
at com.sun.mail.imap.IMAPInputStream.read(IMAPInputStream.java:218)
at com.sun.mail.imap.IMAPInputStream.read(IMAPInputStream.java:244)
at com.sun.mail.imap.IMAPMessage.writeTo(IMAPMessage.java:849)
Run Code Online (Sandbox Code Playgroud)
我查看了 IMAPInputStream 代码,以了解为什么它进行了删除检查,看起来像是获得了ProtocolException.
if (peek)
b = p.peekBody(seqnum, section, pos, cnt, readbuf);
else
b = p.fetchBody(seqnum, section, pos, cnt, readbuf);
} catch (ProtocolException pex) {
forceCheckExpunged();
throw new IOException(pex.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过这种情况?我正在使用 javax.mail-1.5.6
我已经在Google上四处浏览,但找不到任何相关内容。基本上,我想掌握长期运行的事务。
现在,我浏览information_schema.INNODB_TRX或查看的输出show engine innodb status以查找trx_id,然后打开general_logs以查看所有查询正在运行的内容。
有没有办法,我可以transaction_id使用jdbc或在我的代码中掌握这一点,hibernate以便可以将其记录在服务器日志中?
我想使用unpkg如文件建立提到加载UI招摇这里
当它加载它时会抛出一个错误说
No layout defined for "StandaloneLayout"
Run Code Online (Sandbox Code Playgroud)
有人对此有任何想法吗?
java ×2
aws-lambda ×1
hibernate ×1
jakarta-mail ×1
jdbc ×1
jms ×1
junit ×1
mongodb ×1
mysql ×1
spring-junit ×1
swagger-ui ×1
transactions ×1