我正在构建一个Web应用程序,简而言之就是在SQL Server中使用结构相当差的数据,并通过Node.JS将其移植到MongoDB.我需要这个的原因是我需要访问来自编写得相当糟糕的应用程序的数据,该应用程序是组织的核心,我无法更改输入初始数据的代码.翻译后,我可以让我的应用程序执行业务所需的操作.
现在我的应用程序每隔30分钟轮询SQL Server进行更改,然后通过Node.JS更新我的MongoDB,并且由于数据量大,不希望更频繁地轮询.
我需要做的是将SQL Server的实时通知以某种方式推送到我的Node.JS应用程序,无论是主动还是被动,没有Node.JS的结束,以便它可以更新我的Mongo数据库.
我用来获取数据的节点库是:https://github.com/patriksimek/node-mssql
我有一些可能的想法:
有几个似乎在谈论这个,但大多数似乎谈论数据源起点(我不能改变)的变化,而不是从SQL Server本身.
我已经看到了关于这个问题的几个主题,但它们似乎都没有直接回答这个问题.
背景,我在应用程序的其他部分安装了弹簧安全,工作和运行.我的用户名是"开发者".
在Java 7,Glassfish 4,Spring 4上运行,并使用Angular + StompJS
我们在这里得到一些代码:
package com.myapp.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketBrokerConfig extends AbstractWebSocketMessageBrokerConfigurer {
public final static String userDestinationPrefix = "/user/";
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/stomp").withSockJS().setSessionCookieNeeded(true);
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app");
//registry.enableStompBrokerRelay("/topic,/user");
registry.enableSimpleBroker("/topic", "/user");
registry.setUserDestinationPrefix(userDestinationPrefix);
}
}
Run Code Online (Sandbox Code Playgroud)
好的,现在这里是一个控制器,每隔3秒发送一次东西:
import org.springframework.messaging.simp.SimpMessagingTemplate;
…
@Autowired
private SimpMessagingTemplate messagingTemplate;
…
@Scheduled(fixedDelay = 3000)
public void sendStuff ()
{
Map<String, Object> map = new HashMap<>(); …
Run Code Online (Sandbox Code Playgroud) 我希望在序列化之前修改对象.我想编写一个自定义序列化程序来解析对象,然后将其传递给默认对象序列化程序.
这就是我所拥有的:
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
/**
*
* @author Me
*/
public class PersonSerializer extends JsonSerializer<Person>{
@Override
public void serialize(Person value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
//This returns a modified clone of Person value.
Person safePerson = PrivacyService.getSafePerson(value);
provider.defaultSerializeValue(safePerson, jgen);
}
}
Run Code Online (Sandbox Code Playgroud)
但这只是一个无限循环.我也尝试过:
provider.findTypedValueSerializer(Person.class, true, null).serialize(safePerson, jgen, provider);
Run Code Online (Sandbox Code Playgroud)
这可行,但它不解析对象中的任何字段.
我也试过使用a @JsonFilter
但它非常重,并且我的加载时间是六倍.
救命!谢谢!
我正在尝试创建一个Javascript函数,它将返回所有加载的javascript文件.例如:
我加载了jquery.js,jquery.somescript.js和tinymce.js
我想要一个函数以脚本格式返回所有内容(所以如果我要保存并再次运行返回文本)它就像我调用上述文件一样工作.此外,如果TinyMCE加载15个JS fies,它也应该返回.
我希望不要太难以理解,但任何帮助都将不胜感激!
提前致谢!
这是瘦的(向下滚动以查看问题):我正在使用Huffman Encoding来压缩文件(对于一个项目).我制作了地图,并将所有内容都变成了一个字符串,如下所示:
00101010001100001110011101001101111011111011
Run Code Online (Sandbox Code Playgroud)
现在,我需要将其转换为实际的二进制字符串,在当前状态下,它只是一个1和0的字符串.
这是问题所在:
1s和0s的字符串长度为17,747,595个字符,它实际上正在减速到550,000左右
这是我的代码:
<?php
$i=0
$len = strlen($binaryString);
while ($i < $len){
$section = substr($binaryString,$i,$i+8);
$out .= chr(bindec($section));
$i=$i+8;
}
?>
Run Code Online (Sandbox Code Playgroud)
如何才能使这个效率足以运行1700万个字符串?
非常感谢您的支持!
我在几个位置找到了如何使用 Spring boot 制作自定义错误页面,但我似乎无法弄清楚如何使其显示堆栈跟踪。
这就是我所拥有的:
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/WEB-INF/jsp/app/404.jsp");
ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/WEB-INF/jsp/app/500.jsp");
container.addErrorPages(error404Page, error500Page);
}
};
}
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以解决这个问题或者如何开始获取堆栈跟踪?
我试图在这个页面(http://musicaladvocacy.org/)上显示"Home"(灰色渐变中的白色容器)的区域大约60 px,但正如你所看到的那样以及移动父容器.我只是希望白盒子向上移动而不是整个东西.所以看起来应该是这样的:http://musicaladvocacy.org/index-margin.jpg
谢谢你的任何想法!
我正在寻找一个可以有效勾画一个类的函数或类:
class MyClass{
/*
* Perhaps include the function comments
* in the function.
*/
function mainFunction(){
//Does Something
}
function functionWithArgs($arg1,$arg2=false){
//Does Something
//The function I want will give e the arguments w/default values
}
}
Run Code Online (Sandbox Code Playgroud)
是否有一个函数或库可以让我对这个类甚至文件的信息进行某种访问.
恩.
get_file_outline('fileWithAboveClass.php');
要么
get_class_outline('MyClass');
有没有人知道,或知道一种轻松写这个的方法?
我的问题很简单,给出:
class MyClass{
function a(){
echo "F.A ";
}
function b(){
echo "F.B ";
}
}
$c=new MyClass;
$c->a()->b()->b()->a();
Run Code Online (Sandbox Code Playgroud)
所以它会输出:
FA FB FB FA
需要对代码进行哪些更改才能使其工作,或者它应该按原样工作,甚至只是调用它.如果我可以得到任何这个术语,我可以研究它mysqlf,但我不太确定谷歌是什么.
提前致谢!
我基本上可以这样做:
register_function_hook('myFunctionHook');
Run Code Online (Sandbox Code Playgroud)
所以当运行任何函数时:
functionA(); //The hook runs myFunctionHook();
anoterFunction(); //The hook runs myFunctionHook();
Class::functionA(); //The hook runs myFunctionHook();
Run Code Online (Sandbox Code Playgroud)
这样的事情存在吗?
- 编辑 -
我想要做的是获得每个功能的持续时间细分.IE浏览器.性能调优.我想知道在我的Apache服务器上没有安装xDebug时会花费多少时间,但是我不知道是否可能.
我知道如何找到一个图标(或者我认为),但这个网站是不同的:
看看你是否可以找到他们的图标的位置(如果你找到它,你会粘贴它的链接).
我只是要分析它,但现在这是一个委托人的问题,我找不到它:)
是否可以监控每个Spring请求?
就像是:
public class MySpringWatcher extends SpringSomething{
@Override
public HttpServletResponse watchResponse(HttpServletRequest request){
// Starts a timer and counter for analyzing each request made
MyTimerCounter timerCounter = new MyTimerCounter(request);
//Do the request, process Java and JSTL Code
request.doSomething();
// Mark complete and then log results
timerCounter.stop();
}
}
Run Code Online (Sandbox Code Playgroud)
也许
public class MySpringWatcher extends SpringSomething{
MyTimerCounter activeRequest;
@Override
public SpringResponse beforeRequest(HttpServletRequest request){
// Starts a timer and counter for analyzing each request made
activeRequest = new MyTimerCounter(request);
}
@Override
public SpringResponse afterRequest(HttpServletRequest …
Run Code Online (Sandbox Code Playgroud) 我期待编写一个简单的脚本来同时在许多主机上执行SSH命令,并且哪些主机完全是从另一个脚本生成的.问题是,当我使用像sed这样的sometihng运行脚本时,它无法正常工作.
它应该运行sshall.sh {anything here}
,它将{anything here}
在列表中的所有节点上运行该部分.
sshall.sh
#!/bin/bash
NODES=`listNodes | grep "node-[0-9*]" -o`
echo "Connecting to all nodes and running: ${@:1}"
for i in $NODES
do
:
echo "$i : Begin"
echo "----------------------------------------"
ssh -q -o "StrictHostKeyChecking no" $i "${@:1}"
echo "----------------------------------------"
echo "$i : Complete";
echo ""
done
Run Code Online (Sandbox Code Playgroud)
当它运行类似whoami
它的工作但我运行时:
[root@myhost bin]# sshall.sh sed -i '/^somebeginning/ s/$/,appendme/' /etc/myconfig.conf
Connecting to all nodes and running: sed -i /^somebeginning/ s/$/,appendme/ /etc/myconfig.conf
node-1 : Begin
----------------------------------------
sed: -e …
Run Code Online (Sandbox Code Playgroud) java ×4
php ×4
performance ×3
spring ×3
javascript ×2
spring-boot ×2
spring-mvc ×2
algorithm ×1
architecture ×1
bash ×1
binary ×1
c# ×1
class ×1
class-design ×1
css ×1
dynamic ×1
favicon ×1
hook ×1
huffman-code ×1
jackson ×1
json ×1
layer ×1
linux ×1
load ×1
margin ×1
mongodb ×1
node.js ×1
object ×1
oop ×1
outline ×1
overlay ×1
sed ×1
shell ×1
sql-server ×1
ssh ×1
stack-trace ×1
websocket ×1