我正在制作一个需要监控Gmail帐户以查找新邮件的程序,为了尽快获取它们,我正在使用JavaMail的空闲功能.这是我用来调用folder.idle()的线程的代码片段:
//Run method that waits for idle input. If an exception occurs, end the thread's life.
public void run() {
IMAPFolder folder = null;
try {
folder = getFolder();
while(true)
{
//If connection has been lost, attempt to restore it
if (!folder.isOpen())
folder = getFolder();
//Wait until something happens in inbox
folder.idle(true);
//Notify controller of event
cont.inboxEventOccured();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("MailIdleWaiter thread ending.");
}
Run Code Online (Sandbox Code Playgroud)
getFolder()方法基本上打开与IMAP服务器的连接并打开收件箱.
这有效一段时间,但在10分钟左右后它就会停止获取更新(不会抛出任何异常).
我正在寻找保持连接活着的建议.我是否需要第二个线程,其唯一的作用是睡眠并每10分钟更新一次idle()线程,还是有更简单/更好的方法?
提前致谢.
我有一个Spring 3.0.5.RELEASE的应用程序试图使用@RequestBody获取帖子的完整内容.调用该方法,但传递的字符串始终为空.我通过放置断点检查了StringHttpMessageConverter是否被调用,但内部HttpInputMessage是空的.
我已经看过Jetty和Tomcat的这个问题,所以我放弃了容器的问题.
这是我的样本控制器:
@Controller
@RequestMapping("/")
public class SubscriptionController {
@RequestMapping(value = "/requestbody", method = RequestMethod.POST)
public ModelAndView mycustomAction(@RequestBody String body) {
// body is always empty
Logger.getLogger(this.getClass()).debug("REQUEST BODY '" + body + "'");
return new ModelAndView("empty");
}
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序上下文定义如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Enable auto detection of controllers -->
<context:component-scan base-package="com.big.viajerotelcel.controller" />
<!--
use annotation driven mvc and one single validator with JSR-303
standard
-->
<mvc:annotation-driven …Run Code Online (Sandbox Code Playgroud) 我已经使用Font Squirrel创建了@ font-face css规则和所有字体格式,并且在我到目前为止测试的所有浏览器上都能正常工作,但在IE7上却没有.字体似乎根本没有加载.
您可以在http://grupogamma.socialsnack.com/上查看该网站.
@ font-face规则在http://grupogamma.socialsnack.com/wp-content/themes/gamma/style.css上,字体在http://grupogamma.socialsnack.com/fonts/上
我的css片段由Font Squirrel生成:
@font-face {
font-family: 'UniversCondensedLight';
src: url('/fonts/univers-condensedlight-webfont.eot');
src: url('/fonts/univers-condensedlight-webfont.eot?#iefix') format('eot'),
url('/fonts/univers-condensedlight-webfont.woff') format('woff'),
url('/fonts/univers-condensedlight-webfont.ttf') format('truetype'),
url('/fonts/univers-condensedlight-webfont.svg#webfonteM3WTEhs') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'UniversCondensed';
src: url('/fonts/univers-condensed-webfont.eot');
src: url('/fonts/univers-condensed-webfont.eot?#iefix') format('eot'),
url('/fonts/univers-condensed-webfont.woff') format('woff'),
url('/fonts/univers-condensed-webfont.ttf') format('truetype'),
url('/fonts/univers-condensed-webfont.svg#webfontPDfnu2z9') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
编辑:
通过使用Wireshark,我能够验证字体.eot确实已加载,并返回200 OK.content-type是application/vnd.ms-fontobject.所以加载了字体,但是没有使用/没有正确呈现.
我正在使用Jetty的Maven插件,版本7.0.0.pre5,但我在将其配置为具有SSL连接器时遇到问题.每当我启动应用程序时,它都会失败,说明找不到请求的实现.
这是我的pom.xml中的插件配置
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.0.0.pre5</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
</connector>
<connector implementation="org.mortbay.jetty.ssl.SslSelectChannelConnector">
<port>8443</port>
<keystore>src/test/resources/server.keystore</keystore>
<keyPassword>123456</keyPassword>
<password>123456</password>
</connector>
</connectors>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
试图用mvn jetty运行它:run给出以下输出:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for: org.mortbay.jetty:jetty-maven-plugin:7.0.0.pre5
Cause: Class name which was explicitly given in configuration using 'implementation' attribute: 'org.mortbay.jetty.ssl.SslSelectChannelConnector' cannot be loaded
Run Code Online (Sandbox Code Playgroud)
使用org.mortbay.jetty.ssl.SslSocketConnector呈现相同的结果.
这真的很奇怪,因为根据Jetty自己的文档,两个类都存在并且这是它们的正确名称(注意Jetty 6中使用了包安全性而不是ssl).
参考:http: //www.jarvana.com/jarvana/view/org/mortbay/jetty/jetty-assembly/7.0.0.pre5/jetty-assembly-7.0.0.pre5-site-component.jar!/jetty -7.0.0.pre5 /码头-分布- 7.0.0.pre5现场组分/目标/站点/ apidocs /组织/ mortbay /码头/ SSL/SslSocketConnector.html
我有一个使用Spring + Hibernate的Java应用程序.我有一个非常简单的事务,最近刚开始执行(~25秒),虽然它没有进行任何模糊/复杂的查询,并且根据日志,这些25秒是在Hiberante的代码中花费的.浏览器只是挂在那里等待它完成...
事务通过注释完成,使用org.springframework.orm.hibernate3.LocalSessionFactoryBean作为会话工厂,org.springframework.orm.hibernate3.HibernateTransactionManager作为事务管理器.
对于Hibernate的缓存,我正在使用Memcached,但它不应该是一个问题,根据日志至少它在此期间没有触及缓存....
我在这里提交相关的日志:
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|HibernateTransactionManager] Found thread-bound Session [org.hibernate.impl.SessionImpl@a04a093] for Hibernate transaction
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|HibernateTransactionManager] Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@35ca1808]
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|HibernateTransactionManager] Creating new transaction with name [com.quebicoca.api.service.PaymentService.buy]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|HibernateTransactionManager] Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@a04a093]
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|HibernateTransactionManager] Exposing Hibernate transaction as JDBC transaction [com.mysql.jdbc.JDBC4Connection@66efd0ce]
[DEBUG] [2010-10-09 @ 07:25:30] [http-8080-12|TransactionSynchronizationManager] Bound value [org.springframework.jdbc.datasource.ConnectionHolder@a75b92e] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@1420ca8b] to thread [http-8080-12]
[DEBUG] [2010-10-09 @ …Run Code Online (Sandbox Code Playgroud) java ×2
spring ×2
css ×1
font-face ×1
fonts ×1
hibernate ×1
imap ×1
jakarta-mail ×1
jetty ×1
maven-2 ×1
maven-plugin ×1
spring-mvc ×1
transactions ×1